我已按照此处列出的所有步骤操作: https://firebase.google.com/docs/auth/web/cordova,验证了所有信息,但我仍然收到以下错误。
code: "auth/redirect-cancelled-by-user", message: "The redirect operation has been cancelled by the user before finalizing."
以下是我如何调用google login:
consturctor有public afAuth: AngularFireAuth
。和夫妻相关的进口是:
import * as firebase from 'firebase/app';
import { AngularFireAuth } from 'angularfire2/auth';
// signInWithGoogle.
signInWithGoogle(): void {
this.showLoading();
if (this.platform.is('android')) {
console.log("android");
this.provider = new firebase.auth.GoogleAuthProvider();
this.afAuth.auth.signInWithRedirect(this.provider)
.then(function () {
return firebase.auth().getRedirectResult();
})
.then((result: any) => {
if (result) {
this.handleUser(result);
}
})
.catch((error: any) => {
this.hideLoading();
var errorMessage = error.message;
console.log("android login error: ", error);
});
}
if (this.platform.is('core')) {
console.log("in core");
this.provider = new firebase.auth.GoogleAuthProvider();
this.afAuth.auth.signInWithPopup(this.provider)
.then((result: any) => {
if (result) {
this.handleUser(result);
}
})
.catch((error: any) => {
this.hideLoading();
var errorMessage = error.message;
console.log("error: ", error);
});
}
}
以上是我的完整方法。
下面是一个测试项目,所以我将显示所有设置:
<universal-links>
<host name="bhb7m.app.goo.gl" scheme="https" />
<host name="test1-2366d.firebaseapp.com" scheme="https">
<path url="/__/auth/callback" />
</host>
</universal-links>
<preference name="AndroidLaunchMode" value="singleTask" />
我想我必须错过一步,因为我根本无法让它发挥作用。
答案 0 :(得分:2)
问题在于依赖关系。我更新到Cordova 8.0,然后我开始出现构建错误。