Search code examples
cordovaionic-frameworkcordova-pluginsionic4google-plus-signin

cordova-plugin-googleplus stopped working without printing any errors whatsoever #589


It's in an Ionic 4 app. It was working perfectly for a long time, and now I get it simply not working - without any clue. So here is the code :

    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);
          });
        }
      });
    }

Relevant package.json part:

...
    "@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"
      },
...

So it stopped working not long ago, I'm not sure when. What I do know is, when I migrated to Ionic 4 it worked, and now it doesn't. But the thing is, it gives no error at all ! Simply prints in console:

111
222

And then simply nothing. No 333 nor errors.


Solution

  • Found it. I had implemented this fix : https://github.com/arnesson/cordova-plugin-firebase/issues/742#issuecomment-398794131 and so Google Login plugin was simply not compiling correctly - thus the weirdness of what happened. Removed it, removed the plugin from the project, changed code a bit, rebuilt - working like a charm.