Firebase Phone Auth работает в Интернете, но не работает на устройстве Android при возврате ошибки «SMS NOT SENT» и сообщении «auth/operation-not-supported-in-this-environment»
Recaptcha работает в Интернете и не работает на телефоне Android
и документ firebase android предлагает
скомпилировать 'com.google.firebase:firebase-auth:11.6.0' --- добавить в build.gradle
при добавлении и создании сборки
строка зависимости компиляции исчезает из build.gradle
SMS not sent
N {code: "auth/operation-not-supported-in-this-environment", message: "RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment."}
code
:"auth/operation-not-supported-in-this-environment"
message
:"RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment."
__proto__
:Error
Вот мой код
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController} from 'ionic-angular';
import firebase from 'firebase';
/**
* Generated class for the LoginPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-login',
templateUrl: 'login.html',
})
export class LoginPage {
public recaptchaVerifier:firebase.auth.RecaptchaVerifier;
constructor(public navCtrl: NavController, public alertCtrl: AlertController) {}
ionViewDidLoad() {
this.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container',{
'size':'invisible',
'callback':function(responce){
}
});
}
signIn(phoneNumber: number){
const appVerifier = this.recaptchaVerifier;
const phoneNumberString = "+91" + phoneNumber;
firebase.auth().signInWithPhoneNumber(phoneNumberString, appVerifier)
.then( confirmationResult => {
// SMS sent. Prompt user to type the code from the message, then sign the
// user in with confirmationResult.confirm(code).
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 => {
confirmationResult.confirm(data.confirmationCode)
.then(function (result) {
var user = result.user;
// User signed in successfully.
console.log(result.user);
// ...
}).catch(function (error) {
// User couldn't sign in (bad verification code?)
// ...
});
}
}
]
});
prompt.present();
})
.catch(function (error) {
console.error("SMS not sent", error);
});
}
}