EddyVerbruggen / cordova-plugin-googleplus

:heavy_plus_sign: Cordova plugin to login with Google Sign-In on iOS and Android
567 stars 629 forks source link

Error: SignInResult is null. Conflict with other plugins #357

Open saiy2k opened 7 years ago

saiy2k commented 7 years ago

I am working on Ionic 2 app and integrated this plugin for Google login.

It works good in my project with the following plugins:

[ ~/projects/ionic/grmobile ]$ ionic plugins list
cordova-plugin-app-event 1.2.0 "Application Events"
cordova-plugin-camera 2.4.0 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.6 "Console"
cordova-plugin-device 1.1.5 "Device"
cordova-plugin-googleplus 5.1.1 "Google SignIn"
cordova-plugin-network-information 1.3.2 "Network Information"
cordova-plugin-splashscreen 4.0.2 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
de.appplant.cordova.plugin.local-notification 0.8.4 "LocalNotification"
info.protonet.imageresizer 0.1.1 "Image Resizer"
ionic-plugin-keyboard 2.2.1 "Keyboard"

With the same code, it fails with following plugins:

[ ~/projects/ionic/grmobile ]$ ionic plugin list
cordova-plugin-app-event 1.2.0 "Application Events"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-background-mode 0.7.2 "BackgroundMode"
cordova-plugin-badge 0.7.4 "Badges"
cordova-plugin-camera 2.4.0 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.6 "Console"
cordova-plugin-device 1.1.5 "Device"
cordova-plugin-facebook4 1.7.4 "Facebook Connect"
cordova-plugin-file 4.3.2 "File"
cordova-plugin-file-transfer 1.6.2 "File Transfer"
cordova-plugin-firebase 0.1.19 "Google Firebase Plugin"
cordova-plugin-google-analytics 1.7.5 "Google Universal Analytics Plugin"
cordova-plugin-googleplus 5.1.1 "Google SignIn"
cordova-plugin-inappbrowser 1.7.0 "InAppBrowser"
cordova-plugin-network-information 1.3.2 "Network Information"
cordova-plugin-splashscreen 4.0.2 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
cordova-plugin-x-socialsharing 5.1.6 "SocialSharing"
de.appplant.cordova.plugin.local-notification 0.8.4 "LocalNotification"
info.protonet.imageresizer 0.1.1 "Image Resizer"
ionic-plugin-keyboard 2.2.1 "Keyboard"

I will narrow down the exact plugin(s), which is causing the issue and update here.

My code is

window.plugins.googleplus.login({}, function(successMsg) {
  console.log(successMsg);
}, function(errorMsg) {
  console.log(errorMsg);
});

With the 2nd set of plugins, The login always fails with the following message: SignInResult is null

The instant the login function is called, error callback is invoked with the msg SignInResult is null. But in device, Google account creation popup is displayed and when I tap on my account, neither success callback nor failure callback is invoked.

I installed the plugin with following command

ionic plugin add cordova-plugin-googleplus

Posted the same @ http://stackoverflow.com/questions/42813536/error-cordova-plugin-googleplus-signinresult-is-null

im-bhatman commented 7 years ago

Try to implement the same like this:

import { GooglePlus } from '@ionic-native/google-plus';

constructor(private googlePlus: GooglePlus) { }

...

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

In ionic 2 maybe windows.[anything].[anything].. dont work anymore(not sure but in new ionic 2 native docs windows.* type syntax is not shown anywhere).

Also make sure use are using these two commands:(just for a confirmation, i know ou must have done this already)

$ ionic plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=myreversedclientid
$ npm install --save @ionic-native/google-plus

use a proper reserved client id. Link to google plus native : https://ionicframework.com/docs/v2/native/google-plus/

gustavo-iniguez-goya commented 7 years ago

Hi,

In my experience, this problem arises when the device doesn't have the google play services updated. Mostly on android 4.x .

Take a look at the logcat while you complete the sign in flow, and see if the message "_Google Play services out of date. Requires XXXXXX but found XXXXXX" appears.

As a workaround I included a dialog with an explanation for the error and a link to update google play services (which is not always searchable on google play btw). And in some cases it did work.

saiy2k commented 7 years ago

@hackSlanger @gustavo-iniguez-goya Tried both of your solutions, it didn't work.

I cleaned up my code removing unwanted plugins. And Google login worked, when I removed this plugin cordova-plugin-background-mode 0.7.2 specifically.

Will try the same in a Ionic blank project with just googleplus and background-mode and report my finding.

gustavo-iniguez-goya commented 7 years ago

just in case you need it, here's the link to the google play services app: https://play.google.com/store/apps/details?id=com.google.android.gms

I'll keep monitorizing this issue to see if you find a solution.

ashokkumar88 commented 7 years ago

If you are using cordova-plugin-background-mode then add the below in your config.xml

<preference name="AndroidLaunchMode" value="singleTop" />

Heena-Vora commented 6 years ago

@hackSlanger i've implemented same as you've mentioned in your answer. still i get null values in familyName and givenName. Also default scopes are profile and email as in google api docs.

is there anything else i'm missing in configuring gplus sign in?

vijeth-ag commented 6 years ago

I got the same Google Plus "SignInResult is null" error, yet showing user device google account popup behaviour. in my Ionic v1 app

In my case using Angular Material Library was causing the issue.

Turns out Angular Material has some known integration issues with Ionic. Link below: https://material.angularjs.org/1.1.5/getting-started

50l3r commented 4 years ago

i have the same issue with this plugins:

cordova-clipboard 1.3.0 "Clipboard" cordova-custom-config 5.1.0 "cordova-custom-config" cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx" cordova-plugin-androidx-adapter 1.1.0 "cordova-plugin-androidx-adapter" cordova-plugin-customurlscheme 4.4.0 "Custom URL scheme" cordova-plugin-deeplinks 1.1.1 "Cordova Deeplinks Plugin" cordova-plugin-device 2.0.2 "Device" cordova-plugin-facebook4 6.2.0 "Facebook Connect" cordova-plugin-firebasex 7.0.1 "Google Firebase Plugin" cordova-plugin-googleplus 8.2.0 "Google SignIn" cordova-plugin-inappbrowser 3.2.0 "InAppBrowser" cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 4.1.3 "cordova-plugin-ionic-webview" cordova-plugin-network-information 2.0.2 "Network Information" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-statusbar 2.4.2 "StatusBar" cordova-plugin-whitelist 1.3.3 "Whitelist" cordova-plugin-x-socialsharing 5.6.2 "SocialSharing" cordova-support-android-plugin 1.0.1 "cordova-support-android-plugin" cordova-support-google-services 1.3.2 "cordova-support-google-services" es6-promise-plugin 4.2.2 "Promise" phonegap-plugin-mobile-accessibility 1.0.5-dev "Mobile Accessibility"

Maybe cordova-plugin-inappbrowser cause problem?

PD: It has been impossible for me to put line breaks in the code