Ionic Native GooglePlus: unrecognized selector sent to instance

I am using Ionic2 with Cordova to authenticate a user in Firebase.

I can build the app and run it on iOS Simulator (Xcode). However, as soon as I try log in a user with the following code using ionic-native ("ionic-native": "2.2.11",) GooglePlus:

  loginGoogleCordova(): void {
    GooglePlus.login(['public_profile', 'email']).then(googleData => {
      let provider = firebase.auth.GoogleAuthProvider.credential(googleData.authResponse.accessToken);
      firebase.auth().signInWithCredential(provider).then((data) => {
        this.signIn(data);
      });
    }, error => {
      this.loading.dismiss();
      console.error('loginGoogle: ' + error);
      this.doAlert('loginGoogle: ' + error.message);
    });
  }

I get the following error:

2017-03-06 07:55:06.433 theWhoZoo[10489:868996] *** WebKit discarded
an uncaught exception in the
webView:decidePolicyForNavigationAction:request:frame:decisionListener:
delegate: -[__NSArrayM
objectForKeyedSubscript:]: unrecognized selector sent to instance
0x6100002471a0

More Info:

I can successfully authenticate a user in a browser with AngularFire2.

  loginGoogleBrowser() {
    this.auth.login({ provider: AuthProviders.Google, method: AuthMethods.Popup }).then((data: FirebaseAuthState) => {
      this.signIn(data);
    }).catch((error) => {
      this.loading.dismiss();
      console.error('loginGoogle', error);
      this.doAlert('loginGoogle: ' + error.message);
    });
  }

Any help appreciated.

I have the same problem, have you found any solution ?

I just resolved this issue and hope it helps you as well. In Ionic’s documentation they have the example code:
this.googlePlus.login()
.then(res => console.log(res))
.catch(err => console.error(err));

However, as of version 3.4.4, this will cause the error mentioned above. In order to correctly call the login method on the GooglePlus provider you need to pass it the ‘options’ JSON even if it’s empty. In other words by simply replacing your login call from ‘this.googlePlus.login()’ to ‘this.googlePlus.login({})’ you should get past this error.

Please report back if this resolves your issue so that I, or Ionic developers, can address this issue by either fixing the docs or overloading the login method with a version that does not require a parameter.

Update: I submitted a pull request to the ionic-native documentation repo: https://github.com/driftyco/ionic-native/pull/1368

1 Like

Thanks @juanjose49 it worked