React Native Firebase Phone Auth-phoneAuthSnapshot的NULL值用于VerificationId和代码

时间:2019-02-13 06:24:04

标签: firebase react-native firebase-authentication react-native-firebase

我正在尝试使用react-native-firebase进行电话验证。 Firebase设置正确。我可以找回一些电话号码的SMS代码。我正在使用verifyPhoneNumber方法。我的代码如下:

firebase
      .auth()
      .verifyPhoneNumber(phoneNumber)
      .on('state_changed', phoneAuthSnapshot => {
        console.log(phoneAuthSnapshot);
        switch (phoneAuthSnapshot.state) {

phoneAuthSnapshot包含以下内容:

{verificationId: null, code: null, error: null, state: "verified"}

现在,由于verificationId和代码均为NULL,因此我无法建立凭据:

const credential = firebase.auth.PhoneAuthProvider.credential(
  verificationId,
  codeInput
);

由于无法建立凭据,因此无法获取用户详细信息:

firebase
  .auth()
  .signInWithCredential(credential)
  .then(user => {
    console.log('PHONE AUTH USER ->>>>>', user.toJSON());
    this.setState({ user: user.toJSON() });
  })

有人可以帮助解决这个问题吗?

0 个答案:

没有答案