mcnamee / react-native-starter-kit

:rocket: A React Native boilerplate app to get you up and running very, very quickly :rocket:
MIT License
3.35k stars 863 forks source link

is Phone Auth supported on this boilerplate? #128

Closed paritosh-yadav closed 6 years ago

paritosh-yadav commented 6 years ago

Description :- I have to enable Phone Auth in my app. As per docs, i have to call the below method:

window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('sign-in-button', {
  'size': 'invisible',
  'callback': function(response) {
    // reCAPTCHA solved, allow signInWithPhoneNumber.
    onSignInSubmit();
  }
});

to generate a 'recaptchaVerifier' which is going to be user the next method as follows:

var phoneNumber = getPhoneNumberFromUserInput();
var appVerifier = window.recaptchaVerifier;
firebase.auth().signInWithPhoneNumber(phoneNumber, appVerifier)//here as '**appVerifier**'
    .then(function (confirmationResult) {
      // SMS sent. Prompt user to type the code from the message, then sign the
      // user in with confirmationResult.confirm(code).
      window.confirmationResult = confirmationResult;
    }).catch(function (error) {
      // Error; SMS not sent
      // ...
    });

but as i call the method 'firebase.auth.RecaptchaVerifier' , it throws an error saying 'document not defined', when i did some research on this, i found that this method need document to look for specified id as mentioned in its first argument.

So how can i use this in React Native App as per my understanding it don't have document to look for.

Help us reproduce - tell us about your environment

  1. i'm using Mac for development.
  2. "name": "StarterKit", "version": "1.0.0",
  3. Issue is for both iOS and Android

Steps to reproduce

To reproduce the issue, hit below code(as per docs):

    Firebase.auth().useDeviceLanguage();
    let recaptchaVerifier = Firebase.auth.RecaptchaVerifier('sign-in-button', {
      'size': 'normal',
      'callback': function (response) {
        // reCAPTCHA solved, allow signInWithPhoneNumber.
        this.onSignInSubmit();
      }
    });

Expected result

It should ask for captcha verification.

Actual result

It throws an error saying 'Document is not defined'

simulator screen shot - iphone 6 - 2017-12-31 at 19 02 34

mcnamee commented 6 years ago

Hi @paritosh-yadav I'd suggest checking out an alternative Firebase implementation.

This project uses the official Firebase JS implementation, however for your project, it might be worth looking into something like this one, which states that it supports Phone Auth.

Interested to hear how you go/which direction you go in to get Phone Auth working.

paritosh-yadav commented 6 years ago

Hi @mcnamee, Thanks for the response. Actually i have seen that alternative, just wanted to know if its possible in this boilerplate without going to some other implementation.

Thanks...Nice boilerplate