Skip to content

Commit

Permalink
refactor: Improvement/bump gms google auth version (#382)
Browse files Browse the repository at this point in the history
* allow supplying play services auth version & set default to 21.2.0

* update package.lock json to match current version

* check for nullclients on sign-in & sign-out

* correctly return void after nullClient errors
  • Loading branch information
selcuk-sahin authored Aug 1, 2024
1 parent fdee173 commit e808d9e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ plugin first use `androidClientId` if not found use `clientId` if not found use
</resources>
```

Changing Play Services Auth version (Optional) :

This plugin uses `com.google.android.gms:play-services-auth:21.2.0` by default, you can override it providing `gmsPlayServicesAuthVersion` at `variables.gradle`

**Refresh method**

This method should be called when the app is initialized to establish if the user is currently logged in. If true, the method will return an accessToken, idToken and an empty refreshToken.
Expand Down
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ext {
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
gmsPlayServicesAuthVersion = project.hasProperty('gmsPlayServicesAuthVersion') ? rootProject.ext.gmsPlayServicesAuthVersion : '21.2.0'
}

buildscript {
Expand Down Expand Up @@ -57,5 +58,5 @@ dependencies {
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation 'com.google.android.gms:play-services-auth:18.+'
implementation "com.google.android.gms:play-services-auth:$gmsPlayServicesAuthVersion"
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public void load() {}

@PluginMethod()
public void signIn(PluginCall call) {
if(googleSignInClient == null){
rejectWithNullClientError(call);
return;
}
Intent signInIntent = googleSignInClient.getSignInIntent();
startActivityForResult(call, signInIntent, "signInResult");
}
Expand Down Expand Up @@ -155,6 +159,10 @@ public void refresh(final PluginCall call) {

@PluginMethod()
public void signOut(final PluginCall call) {
if(googleSignInClient == null){
rejectWithNullClientError(call);
return;
}
googleSignInClient.signOut()
.addOnSuccessListener(getActivity(), new OnSuccessListener<Void>() {
@Override
Expand Down Expand Up @@ -257,4 +265,8 @@ private static String fromStream(InputStream is) throws IOException {
reader.close();
return sb.toString();
}

private void rejectWithNullClientError(final PluginCall call) {
call.reject("Google services are not ready. Please call initialize() first");
}
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e808d9e

Please sign in to comment.