使用FireBase进行React Native的电话号码身份验证

时间:2020-01-15 15:48:25

标签: node.js firebase react-native constructor firebase-authentication

我收到称为undefined的错误,不是构造函数(正在评估'new_firebase.default.auth.RecaptchaVerifier')

//React-Native Design Part

  <View style = {styles.buttonStyle} >  
    <Button 
    title = 'Next'
    id = 'next-button'
      onPress={this.NextButton.bind(this)}
      color="#6a0dad">
    </Button>  
  </View>


//Node JS Firebase Authentication part


NextButton() {
    console.log(this.state.number);   //The Phone Number recieved from the User.
    firebase.auth().languageCode = 'it';


    window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('next-button', {
      'size': 'invisible',
      'callback': function(response) {
        var phoneNumber = this.state.number;
        var appVerifier = window.recaptchaVerifier;
        firebase.auth().signInWithPhoneNumber(phoneNumber, appVerifier)
    .then(function (confirmationResult) {

        this.props.navigation.navigate('Number');

      // 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
      // ...
    });
        onSignInSubmit();
      }
    });
}

我是Firebase和Node JS的新手。请帮助我。

0 个答案:

没有答案