Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
#95 Crash when using isAvailable method before login
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Aug 20, 2015
1 parent 95cae83 commit 04d1bf3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-googleplus"
version="4.0.0">
version="4.0.1">

<name>Google+</name>

Expand Down
13 changes: 7 additions & 6 deletions src/android/GooglePlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand All @@ -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();

Expand Down

0 comments on commit 04d1bf3

Please sign in to comment.