Advertisement
Guest User

Untitled

a guest
May 22nd, 2021
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. const sendSMSCode = async (phone, resolve, reject, { url }) => {
  2. Platform.OS === 'ios' && WebBrowser.dismissBrowser();
  3.  
  4. const tokenEncoded = Linking.parse(url).queryParams['token'];
  5. if (tokenEncoded) {
  6. const token = decodeURIComponent(tokenEncoded);
  7. //fake firebase.auth.ApplicationVerifier
  8. const captchaVerifier = {
  9. type: 'recaptcha',
  10. verify: () => Promise.resolve(token)
  11. };
  12. try {
  13. const confirmationResult = await firebase
  14. .auth()
  15. .signInWithPhoneNumber(phone, captchaVerifier);
  16.  
  17. resolve(async smsCode => {
  18. try {
  19. await confirmationResult.confirm(smsCode);
  20. } catch (e) {
  21. console.warn(e);
  22. }
  23. });
  24. } catch (e) {
  25. reject(e);
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement