cordova-plugin-googleplus 停止工作而没有打印任何错误 #589
cordova-plugin-googleplus stopped working without printing any errors whatsoever #589
它在 Ionic 4 应用程序中。它在很长一段时间内都运行良好,现在我发现它根本无法运行 - 没有任何线索。所以这是代码:
doGoogleLogin() {
console.log(111);
return new Promise<any>((resolve, reject) => {
if (this.platform.is('cordova')) {
console.log(222);
this.googlePlus.login({
'scopes': '',
'webClientId': environment.google_web_client_id,
'offline': true
}).then((response) => {
console.log(333, response);
const googleCredential = firebase.auth.GoogleAuthProvider.credential(response.idToken);
firebase.auth().signInWithCredential(googleCredential)
.then((user) => {
console.log(444, user);
resolve({
id: user.uid,
originUserId: response.userId,
email: response.email,
first_name: response.givenName,
last_name: response.familyName,
image: response.imageUrl
});
});
}, (err) => {
console.log(err);
reject(err);
});
}
});
}
相关package.json部分:
...
"@ionic-native/google-plus": "^5.2.0",
...
"cordova-plugin-googleplus": "^7.0.0",
"cordova-support-google-services": "1.2.1",
...
"cordova-plugin-googleplus": {
"REVERSED_CLIENT_ID": "com.googleusercontent.apps.myid",
"WEB_APPLICATION_CLIENT_ID": "myid.apps.googleusercontent.com",
"PLAY_SERVICES_VERSION": "11.8.0"
},
...
所以它不久前就停止工作了,我不确定什么时候。我所知道的是,当我迁移到 Ionic 4 时它起作用了,现在却不起作用了。但问题是,它根本没有给出任何错误!只需在控制台中打印:
111
222
然后就什么都没有了。没有 333
也没有错误。
找到了。我已经实施了此修复:https://github.com/arnesson/cordova-plugin-firebase/issues/742#issuecomment-398794131 等 Google 登录插件根本无法正确编译 - 因此发生的事情很奇怪。删除它,从项目中删除插件,稍微更改一下代码,重新构建 - 工作起来非常棒。
它在 Ionic 4 应用程序中。它在很长一段时间内都运行良好,现在我发现它根本无法运行 - 没有任何线索。所以这是代码:
doGoogleLogin() {
console.log(111);
return new Promise<any>((resolve, reject) => {
if (this.platform.is('cordova')) {
console.log(222);
this.googlePlus.login({
'scopes': '',
'webClientId': environment.google_web_client_id,
'offline': true
}).then((response) => {
console.log(333, response);
const googleCredential = firebase.auth.GoogleAuthProvider.credential(response.idToken);
firebase.auth().signInWithCredential(googleCredential)
.then((user) => {
console.log(444, user);
resolve({
id: user.uid,
originUserId: response.userId,
email: response.email,
first_name: response.givenName,
last_name: response.familyName,
image: response.imageUrl
});
});
}, (err) => {
console.log(err);
reject(err);
});
}
});
}
相关package.json部分:
...
"@ionic-native/google-plus": "^5.2.0",
...
"cordova-plugin-googleplus": "^7.0.0",
"cordova-support-google-services": "1.2.1",
...
"cordova-plugin-googleplus": {
"REVERSED_CLIENT_ID": "com.googleusercontent.apps.myid",
"WEB_APPLICATION_CLIENT_ID": "myid.apps.googleusercontent.com",
"PLAY_SERVICES_VERSION": "11.8.0"
},
...
所以它不久前就停止工作了,我不确定什么时候。我所知道的是,当我迁移到 Ionic 4 时它起作用了,现在却不起作用了。但问题是,它根本没有给出任何错误!只需在控制台中打印:
111
222
然后就什么都没有了。没有 333
也没有错误。
找到了。我已经实施了此修复:https://github.com/arnesson/cordova-plugin-firebase/issues/742#issuecomment-398794131 等 Google 登录插件根本无法正确编译 - 因此发生的事情很奇怪。删除它,从项目中删除插件,稍微更改一下代码,重新构建 - 工作起来非常棒。