每当我尝试使用 react-native-firebase sdk 使用电话号码登录时,我都会通过短信收到 OTP 代码,当我提交收到的代码时,会出现错误消息:“短信代码已过期。请重新发送验证码再试一次。” 在这里要注意的是,即使出现错误,相应电话号码的条目也会写入 firebase 的“用户”部分。
我正在使用以下内容:
NodeJS: v8.11.1,
NPM: v5.6.0,
react-native: "^0.59.9",
react-native-firebase: "^5.5.3"
Run Code Online (Sandbox Code Playgroud)
我已经尝试过的一些链接是:
1. https://github.com/invertase/react-native-firebase-
docs/blob/master/docs/auth/phone-auth.md
2. /sf/ask/3256590851/
authentication-error-the-sms-code-has-expired
3. https://www.bountysource.com/issues/45308170-firebase-phone-
number-auth-integration
4. https://medium.com/@chrisbianca/getting-started-with-firebase-
authentication-on-react-native-a1ed3d2d6d91
5. https://invertase.io/oss/react-native-firebase/v6/auth/phone-
auth
Run Code Online (Sandbox Code Playgroud)
在 MobileRegistration.js 中:
navigateToOtpScreen() {
console.log("Phone number: ", "+91" + this.state.phoneNumber)
firebase.auth().signInWithPhoneNumber("+91" +
this.state.phoneNumber)
.then(confirmResult => {
this.setState({ confirmResult, message: 'Code has been sent!'})
this.props.navigation.navigate('EnterOtp', { 'confirmResult':
confirmResult})
})
.catch(error => {
alert(error.message);
this.setState({ message: `Sign In With Phone Number Error:
${error.message}` })
});
Run Code Online (Sandbox Code Playgroud)
};
在 …
react-native firebase-authentication react-native-android react-native-firebase