首页 文章

Ionic Native GooglePlus登录失败,没有任何错误

提问于
浏览
4

我按照https://ionicframework.com/docs/native/google-plus/的说明进行操作 .

我使用正确的SHA-1在https://console.cloud.google.com/apis/credentials/oauthclient创建了Android客户端(使用 keytool -list -printcert -jarfile <path to your apk> 重新检查)

登录代码很简单,如说明:

this.googlePlus.login({})
.then(res => console.log(res))
.catch(err => console.error(err));

然而,它既没有 then 也没有 catch . 控制台中不显示错误 .

离子版3.20.0

Cordova版本7.1.0

Ionic Native GooglePlus 5.3.0

Android手机版5.1.1

cordova-plugin-googleplus 5.3.0

我花了两天时间,Ionic Native Facebook工作正常,而GooglePlus只是默默地失败了 .

请指教 .

UPDATE 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插件中无法正常工作 .

5 回答

  • 0

    最后,找到了根本原因和解决方案 . 问题发生的原因是Google更新了所有com.google.android.gms:play- *模块,这影响了所有Google服务的cordova插件 .

    如果您只使用Google Plus插件,那么一切都应该没问题 .

    在其他情况下,project.properties中的所有依赖项, com.google.android.gms:play-* 的plugin.xml文件应替换为旧版本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

    UPDATE 08.10.2018

    上次更新后,插件再次无法正常工作 . 问题发生的原因是“com.google.android.gms:play-services-:”的版本冲突 .

    例如,Google Maps插件使用的 com.google.android.gms:play-services-maps:15.0.1 和Google Plus插件使用的 com.google.android.gms:play-services-auth:11.8.0 .

    解决方案很简单:

    • config.xml 中将 <variable name="PLAY_SERVICES_VERSION" value="15.0.1" /> (而不是 15.0.1 可能有更新版本/旧版本)添加到每个使用播放服务的插件中 - 通常所有插件都与Google服务相关 .

    • platforms/android/project.properties 随处使用播放服务版本 15.0.1 (这里的版本与第1点相同) .

  • 0

    谢谢海洛因的答案 . 我的问题是:

    1)com.google.android.gms:play-services-tagmanager:

    2)com.google.android.gms:play-services-auth:11.8.0

    3)com.google.android.gms:play-services-identity:11.8.0

    我做了什么来修复它是因为海洛因建议,但我删除了11.8.0 for 2)和3)并且用“”替换它 . 然后我进入config.xml发现:

    变量名=“PLAY_SERVICES_VERSION”值=“11.8.0”

    正如海洛因建议的那样,然后用“”取代“11.8.0” . 重新编译并运行,现在google plus再次运行 .

  • 7

    我试图改变android / project.properties,google_auth和identity的行

    cordova.system.library.5=com.google.android.gms:play-services-auth:+ cordova.system.library.6=com.google.android.gms:play-services-identity:+

  • 1
    I  used com.google.android.gms:play-services-auth:11.8.0 but still popup is not coming. No error. it never comes into neither then nor catch. No error is displayed in console.
    
    Tried below code :
    
    <code>
          if (this.platform.is('cordova')) {
            this.googlePlus.login({
              'scopes': '', // optional, space-separated list of scopes, If not included or empty, defaults to `profile` and `email`.
              'webClientId': environment.googleWebClientId, // optional clientId of your Web application from Credentials settings of your project - On Android, this MUST be included to get an idToken. On iOS, it is not required.
              'offline': true
            }).then((response) => {
              const googleCredential = firebase.auth.GoogleAuthProvider.credential(response.idToken);
              firebase.auth().signInWithCredential(googleCredential)
              .then(user => {
                console.log("Firebase success: " + JSON.stringify(user));
                resolve();
            });
            },(err) => {
             console.log("Error in doGoogleLogin " + err);
              reject(err);
            });
          }
    </code>
    
  • 4

    在我的情况下同样的事情是讨厌,我试了近1个月,最后对我有用的是我删除了我的插件文件夹并删除了android平台并再次添加它 . 它对我有用 . 希望它会帮助某人 .

相关问题