Здесь ниже приведен исходный код, который я использую для аутентификации телефона Firebase.Это работает нормально в браузере.Но как только я создаю файл .apk и тестирую на своем телефоне Android, это показывает мне исключение.предупреждение («Ошибка: SMS не отправлено»);Это означает, что следующая строка не работает на телефоне.firebase.auth (). signInWithPhoneNumber (phoneNumberString, appVerifier)
В чем может быть проблема?
Пожалуйста, нажмите здесь, чтобы увидеть исходный код
let autSer = this.authService;
const appVerifier = this.recaptchaVerifier;
if (this.phone.indexOf('+') <= -1) {
this.phone = "+" + this.phone;
}
const phoneNumberString = "+" + this.phone;
firebase.auth().signInWithPhoneNumber(phoneNumberString, appVerifier)
//this.afAuth.auth.signInWithPhoneNumber(phoneNumberString,appVerifier)
.then( confirmationResult => {
// SMS sent. Prompt user to type the code from the message, then sign the
// confirmationResult.verificationId
let prompt = this.alertCtrl.create({
title: 'Enter the Confirmation code',
inputs: [{ name: 'confirmationCode', placeholder: 'Confirmation Code' }],
buttons: [
{ text: 'Cancel',
handler: data => { console.log('Cancel clicked'); }
},
{ text: 'Send',
handler: data => {
// Here we need to handle the confirmation code
let signInCredential = firebase.auth.PhoneAuthProvider.credential(confirmationResult.verificationId, data.confirmationCode);
autSer.loginWithPhone(signInCredential).subscribe(authData => {
this.navCtrl.setRoot(HomePage);
}, error => {
// in case of login error
let alert = this.alertCtrl.create({
message: error.message,
buttons: ['OK']
});
alert.present();
});
}
}
]
});
prompt.present();
})
.catch(function (error) {
alert("Error: SMS not sent");
console.log("Error: SMS not sent");
alert(error);
});
}