我正在尝试使用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() });
})
有人可以帮助解决这个问题吗?