diff --git a/README.md b/README.md index 096ac500..43e1b4ff 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,7 @@ window.plugins.googleplus.disconnect( - A: On Android you need to execute the `keytool` steps, see the installation instructions for details. ## 8. Changelog +4.0.1: Login on Android would crash the app if `isAvailable` was invoked beforehand. 4.0.0: Removed the need for `iosApiKey`, reverted Android to Google playservices framework for wider compatibility, documented scopes feature a bit. 3.0.0: Using Google Sign-In for iOS, instead of Google+. 1.1.0: Added `isAvailable`, for issue [#37](https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/37) diff --git a/package.json b/package.json index 6f4da4d2..a8269161 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.0.0", + "version": "4.0.1", "name": "cordova-plugin-googleplus", "cordova_name": "Google+", "description": "Use your Google account to authenticate with the app.", diff --git a/plugin.xml b/plugin.xml index eaedf17f..45538c4d 100755 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="4.0.1"> Google+ diff --git a/src/android/GooglePlus.java b/src/android/GooglePlus.java index a690dad1..d21a97a7 100644 --- a/src/android/GooglePlus.java +++ b/src/android/GooglePlus.java @@ -68,13 +68,15 @@ public void initialize(CordovaInterface cordova, CordovaWebView webView) { public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException { this.savedCallbackContext = callbackContext; - if (args.optJSONObject(0) != null){ + if (args.optJSONObject(0) != null) { JSONObject obj = args.getJSONObject(0); - System.out.println(obj); this.webKey = obj.optString(ARGUMENT_WEB_KEY, null); this.apiKey = obj.optString(ARGUMENT_ANDROID_KEY, null); this.setupScopes(obj.optString(ARGUMENT_SCOPES, null)); + // possible scope change, so force a rebuild of the client + this.mGoogleApiClient = null; } + //It's important that we build the GoogleApiClient after setting up scopes so we know which scopes to request when setting up the google services api client. buildGoogleApiClient(); @@ -156,9 +158,9 @@ private synchronized GoogleApiClient buildGoogleApiClient() { } GoogleApiClient.Builder builder = new GoogleApiClient.Builder(webView.getContext()) - .addConnectionCallbacks(this) - .addOnConnectionFailedListener(this) - .addApi(Plus.API, Plus.PlusOptions.builder().build()); + .addConnectionCallbacks(this) + .addOnConnectionFailedListener(this) + .addApi(Plus.API, Plus.PlusOptions.builder().build()); for (Scope scope : this.scopes) { builder.addScope(scope); @@ -168,7 +170,6 @@ private synchronized GoogleApiClient buildGoogleApiClient() { return this.mGoogleApiClient; } - @SuppressWarnings({ "unchecked", "rawtypes" }) private void resolveToken(final String email, final JSONObject result) { final Context context = this.cordova.getActivity().getApplicationContext();