我按照 https://ionicframework.com/docs/native/google-plus/ 的指示进行操作.
我在 https://console.cloud.google.com/apis/credentials/oauthclient 中创建了 Android 客户端使用正确的 SHA-1(使用 keytool -list -printcert -jarfile <path to your apk>
重新检查)
登录代码很简单,如下所示:
this.googlePlus.login({})
.then(res => console.log(res))
.catch(err => console.error(err));
然而,它从来没有进入过
then
也不是 catch
.控制台中没有显示错误。
ionic 版本 3.20.0
Cordova 7.1.0 版
ionic 原生 GooglePlus 5.3.0
安卓手机版本5.1.1
Cordova 插件 googleplus 5.3.0
我花了两天时间,Ionic Native Facebook 工作正常,而 GooglePlus 只是默默地失败。
请指教。
更新 1
cordova-plugin-googleplus
似乎有问题,就像我在更改 GooglePlus.execute
时一样使用@Override
public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
this.savedCallbackContext = callbackContext;
savedCallbackContext.error(42);
action = "abracadabra";
... //remains unchanged
然后我在 Chrome 控制台 42 中看到 - 这意味着错误处理在 cordova-plugin-googleplus 插件中无法正常工作。
最佳答案
最后,找到了根本原因和解决方案。问题的发生是因为 Google 更新了所有 com.google.android.gms:play-* 模块,这影响了所有 Google 服务 cordova 插件。
如果您只使用 Google Plus 插件,那么我认为一切都应该没问题。
在其他情况下,project.properties、plugin.xml 文件中的所有依赖项都为 com.google.android.gms:play-*
应替换为旧版本 11.8.0:
曾是
com.google.android.gms:play-services-auth:+
应该
com.google.android.gms:play-services-auth:11.8.0
我知道,这最好称为解决方法,但没有其他解决方案有效。
感谢以下人员:
https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/492
https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/484
https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/488
更新 08.10.2018
上次更新后,插件再次无法正常工作。
这个问题是由于 com.google.android.gms:play-services-:` 的版本冲突而发生的。
例如,
com.google.android.gms:play-services-maps:15.0.1
,由 Google map 插件和 com.google.android.gms:play-services-auth:11.8.0
使用由 Google Plus 插件使用。解决方案很简单:
config.xml
把 <variable name="PLAY_SERVICES_VERSION" value="15.0.1" />
(而不是 15.0.1
可能有更新/旧版本)每个使用播放服务的插件 - 通常所有与 Google 服务相关的插件。 platforms/android/project.properties
随处使用播放服务版本 15.0.1
(这里的版本应该与第 1 点相同)。 关于cordova - Ionic Native GooglePlus 登录失败,没有任何错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50248555/