Javascript 使用firebase从react native发送OTP时遇到问题
我正在尝试使用firebase从react native发送OTP,但它不起作用。我收到一个错误“找不到主机名”。我想了解这个发送OTP在使用firebase的移动应用程序中是如何工作的。我可以通过安装.apk而不是将.apk上传到play store来测试mobile/local中的OTP功能吗 我执行了以下配置步骤:Javascript 使用firebase从react native发送OTP时遇到问题,javascript,firebase,react-native,firebase-authentication,Javascript,Firebase,React Native,Firebase Authentication,我正在尝试使用firebase从react native发送OTP,但它不起作用。我收到一个错误“找不到主机名”。我想了解这个发送OTP在使用firebase的移动应用程序中是如何工作的。我可以通过安装.apk而不是将.apk上传到play store来测试mobile/local中的OTP功能吗 我执行了以下配置步骤: 在firebase控制台中创建项目 选择手机作为身份验证下的登录方法 添加了移动应用程序并下载了google-services.json,并在我的代码中的firebase属性中
const phoneProvider = new firebase.auth.PhoneAuthProvider();
console.log('Phone provider ', phoneProvider);
phoneProvider.verifyPhoneNumber(this.state.mobileNumber, this.recaptchaVerifier.current).then((phoneAuthSnapshot) => {
// verification sent
console.log('Verification code sent');
this.setState({
status: 'Confirmation code sent.',
verificationId: phoneAuthSnapshot.verificationId,
//showCodeInput: true // shows input field such as react-native-confirmation-code-field
});
验证OTP
firebase
.auth()
.signInWithCredential(credential)
.then((result) => {
// Do something with the results here
console.log(result);
this.props.navigation.navigate('Home');
}).catch((error) => {
console.log('error sending code ', error);
this.setState({
showFailureDialog: true,
failureMessage: 'OTP did not matched ' + error
})
您可以通过在手机中安装apk来测试OTP功能。您还可以在firebase控制台中包含一些随机数和otp,以检查身份验证过程。(身份验证->登录方法->电话->添加测试电话号码)
要设置OTP身份验证,几乎所有您需要做的就是将应用程序的SHA-1指纹添加到应用程序中。(项目设置->您的应用->适用于android的SHA证书指纹)您可以通过在手机中安装apk来测试OTP功能。您还可以在firebase控制台中包含一些随机数和otp,以检查身份验证过程。(身份验证->登录方法->电话->添加测试电话号码) 要设置OTP身份验证,几乎所有您需要做的就是将应用程序的SHA-1指纹添加到应用程序中。(适用于android的项目设置->应用->SHA证书指纹)