
[英]Ionic IOS Google Log-In mobile “location.protocol” Cordova
[英]Ionic 5 and Cordova: Google Log In works on web browser developer but not on mobile phone
我正在尝试在我的应用程序中实现 Google 登录。 我使用ionic serve通过web浏览器开发运行程序; 和谷歌登录工作。 然而,当我尝试在我的 android 移动设备中构建时,弹出窗口出现了,我输入了我的谷歌帐户详细信息以登录我的应用程序。 没有引导我到主页,它仍然停留在登录页面,有人知道吗?
用户.model.ts
export class FirebaseUserModel {
image: string;
name: string;
provider: string;
constructor() {
this.image = '';
this.name = '';
this.provider = '';
}
}
auth.service.ts
GoogleLogin() {
return new Promise<FirebaseUserModel>((resolve, reject) => {
if (this.platform.is('cordova')) {
this.googlePlus.login({
'scopes': '',
'webClientId': environment.firebaseConfig.googleWebClientId,
'offline': true
}).then((response) => {
const googleCredential = firebase.auth.GoogleAuthProvider.credential(response.idToken);
firebase.auth().signInWithCredential(googleCredential)
.then((user) => {
this.router.navigateByUrl('/tabs/main');
resolve();
});
}, (err) => {
reject(err);
});
} else {
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider)
.then((user) => {
this.router.navigateByUrl('/tabs/main');
}, (err) => {
reject(err);
});
}
});
}
登录页面.ts
tryGoogleLogin() {
this.authService.GoogleLogin()
.then((res) => {
console.log(res);
}, (err) => {
this.errorMessage = err.message;
});
}
很多帮助将不胜感激。 感谢大家。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.