Skip to content

Commit

Permalink
refactor(android): separate messages for signin exception (#176)
Browse files Browse the repository at this point in the history
* added status code for android implementation

* added iOS error code

Co-authored-by: Philipp Heuer <[email protected]>
  • Loading branch information
hoi4 and philipp-stsm authored Feb 1, 2022
1 parent 8bd4ce9 commit 585c8bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public class GoogleAuth extends Plugin {
private final static String FIELD_TOKEN_EXPIRES_IN = "expires_in";
private final static String FIELD_ACCESS_TOKEN = "accessToken";
private final static String FIELD_TOKEN_EXPIRES = "expires";

// see https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInStatusCodes#SIGN_IN_CANCELLED
private final static int SIGN_IN_CANCELLED = 12501;

public static final int KAssumeStaleTokenSec = 60;

private GoogleSignInClient googleSignInClient;
Expand Down Expand Up @@ -121,7 +125,11 @@ protected void signInResult(PluginCall call, ActivityResult result) {
}
});
} catch (ApiException e) {
call.reject("Something went wrong", e);
if (SIGN_IN_CANCELLED == e.getStatusCode()) {
call.reject("The user canceled the sign-in flow.", "" + e.getStatusCode());
} else {
call.reject("Something went wrong", "" + e.getStatusCode());
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion ios/Plugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class GoogleAuth: CAPPlugin {

self.googleSignIn.signIn(with: self.googleSignInConfiguration, presenting: presentingVc) { user, error in
if let error = error {
self.signInCall?.reject(error.localizedDescription);
self.signInCall?.reject(error.localizedDescription, "\(error._code)");
return;
}
if self.additionalScopes.count > 0 {
Expand Down

0 comments on commit 585c8bd

Please sign in to comment.