Angular Firebase web OTP未在移动设备上提供
我正在尝试使用Firebase mobile获取OTP 我已启用移动选项。本地主机被授权为域。我的应用程序正在运行http://localhost:8101/. 当我运行我的应用程序时,添加手机号码并请求OTP,它会返回verificationId。附上截图 问题:手机未收到OTP短信 我的login.ts代码sendOTP是发送OTP的函数:Angular Firebase web OTP未在移动设备上提供,angular,firebase,ionic-framework,firebase-authentication,Angular,Firebase,Ionic Framework,Firebase Authentication,我正在尝试使用Firebase mobile获取OTP 我已启用移动选项。本地主机被授权为域。我的应用程序正在运行http://localhost:8101/. 当我运行我的应用程序时,添加手机号码并请求OTP,它会返回verificationId。附上截图 问题:手机未收到OTP短信 我的login.ts代码sendOTP是发送OTP的函数: import { Component, OnInit } from '@angular/core'; import * as firebase from
import { Component, OnInit } from '@angular/core';
import * as firebase from 'firebase';
import {WindowsService} from '../service/windows.service';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {
otpSent: boolean = false;
recaptchaVerifier;
otpconfirmationResult: firebase.auth.ConfirmationResult;
phoneNumber:string = "";
confirmationResult: firebase.auth.ConfirmationResult;
constructor(public windowService : WindowsService) {
}
//Initiate windowRef from WindowService
async ionViewWillEnter(){
}
ngOnInit() {
this.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container', { 'size': 'invisible' });
}
sendOTP() {
let concatphone = "+91" + (<HTMLInputElement>document.getElementById("phoneNumber")).value;
console.log(concatphone);
firebase.auth().signInWithPhoneNumber(concatphone, this.recaptchaVerifier).then(data => {
this.phoneNumber = concatphone;
this.otpSent = true;
this.confirmationResult = data;
console.log(data);
}).catch(err => {
console.log(err);
})
}
verifyOTP() {
let otpphone = (<HTMLInputElement>document.getElementById("otpphone")).value;
this.otpconfirmationResult.confirm(otpphone).then((data) => {
console.log(data);
// You can redirect to other protected route.
}).catch(err => {
console.log(err);
})
}
}
<ion-header>
<ion-toolbar>
<ion-title>login</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<div id="recaptcha-container" style="display: none;"></div>
<div *ngIf="!otpSent">
<ion-item>
<ion-label position="floating">Phone Number</ion-label>
<ion-input id="phoneNumber"></ion-input>
</ion-item>
<ion-item lines="none">
<ion-label>
<ion-note>
OTP will be sent to this phone number
</ion-note>
</ion-label>
</ion-item>
<ion-button (click)="sendOTP()" expand="block">
Send OTP
</ion-button>
</div>
<div *ngIf="otpSent">
<ion-item>
<ion-label position="floating">Enter OTP Received</ion-label>
<ion-input id="otpphone"></ion-input>
</ion-item>
<ion-item lines="none">
<ion-label>
<ion-note>
OTP sent to {{phoneNumber}}
</ion-note>
</ion-label>
</ion-item>
<ion-button (click)="verifyOTP()" expand="block">
Verify OTP
</ion-button>
</div>
</ion-content>