我在Ionic 4上的应用程序中实现了Firebase提供的身份验证服务,该应用程序不是本机,因此当您尝试使用google登录时,它显示一条消息,说明该应用程序受限制,因为它无法显示弹出窗口在移动设备中,查看Firebase文档后,发现该https://firebase.google.com/docs/auth/web/cordova包含该指南,因此能够在移动设备屏幕上显示google身份验证,这里的问题是,当我运行ionic serve命令时,它可以在浏览器中完美运行,但是,当我尝试查看手机的外观时,它不管用,只要我尝试在手机或任何模拟器上连接到该应用程序,它就会显示以下内容: enter image description here
我不介意那里发生的事情,代码:
import { Router } from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormControl, Validators } from '@angular/forms';
import { AngularFireAuth } from '@angular/fire/auth';
import { auth } from 'firebase/app';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {
login: FormGroup;
correo: string;
password: string;
provider = new auth.GoogleAuthProvider();
constructor(private rutas: Router, public afAuth: AngularFireAuth) {
this.login = new FormGroup({
'EmailLogin': new FormControl ('', [Validators.required,
Validators.email]),
'PwLogin': new FormControl ('', [Validators.required,
Validators.minLength(8)])
});
}
// Email & Password auth
async loginInput() {
const {correo, password} = this;
try {
const res = await this.afAuth.auth.signInWithEmailAndPassword(correo,
password);
} catch (error) {
console.dir(error);
}
// Google Authentication
login2() {
this.afAuth.auth.signInWithRedirect(this.provider).then(function() {
return this.afAuth.auth.getRedirectResult();
}).then(function(result) {
const token = result.credential.accessToken;
const user = result.user;
if (token) {
this.rutas.navigateByUrl('/user');
}
}).catch(function(error) {
const erroCode = error.code;
const errorMsge = error.message;
});
}