diff --git a/.eslintignore b/.eslintignore index f26efcee..394522f4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1 @@ -**/node_modules/** -node_modules/ +node_modules/** \ No newline at end of file diff --git a/README.md b/README.md index b782b279..e733408c 100755 --- a/README.md +++ b/README.md @@ -641,7 +641,7 @@ Please read https://developers.google.com/fit/improvements why we made the chang deleteWeight(options, callback); // method to delete weights by options (same as in delete hydration) - openFit(); //method to open google fit app + openFit(callback); //method to open google fit app saveHeight(options, callback); diff --git a/android/src/main/java/com/reactnative/googlefit/GoogleFitManager.java b/android/src/main/java/com/reactnative/googlefit/GoogleFitManager.java index fe532be3..de8ec47b 100644 --- a/android/src/main/java/com/reactnative/googlefit/GoogleFitManager.java +++ b/android/src/main/java/com/reactnative/googlefit/GoogleFitManager.java @@ -196,7 +196,7 @@ public void disconnect(Context context) { .build(); GoogleSignInClient googleSignInClient = GoogleSignIn.getClient(context, options); - GoogleSignInAccount gsa = GoogleSignIn.getAccountForScopes(mReactContext, new Scope(Scopes.FITNESS_ACTIVITY_READ)); + GoogleSignInAccount gsa = GoogleSignIn.getAccountForScopes(mReactContext, new Scope("https://www.googleapis.com/auth/fitness.activity.read")); Fitness.getConfigClient(mReactContext, gsa).disableFit(); mApiClient.disconnect(); diff --git a/android/src/main/java/com/reactnative/googlefit/GoogleFitModule.java b/android/src/main/java/com/reactnative/googlefit/GoogleFitModule.java index ac81e47b..b8bc09ce 100644 --- a/android/src/main/java/com/reactnative/googlefit/GoogleFitModule.java +++ b/android/src/main/java/com/reactnative/googlefit/GoogleFitModule.java @@ -326,13 +326,15 @@ public void isEnabled(Callback errorCallback, Callback successCallback) { // tru } @ReactMethod - public void openFit() { + public void openFit(Callback errorCallback, Callback successCallback) { PackageManager pm = mReactContext.getPackageManager(); try { Intent launchIntent = pm.getLaunchIntentForPackage(GOOGLE_FIT_APP_URI); mReactContext.startActivity(launchIntent); + successCallback.invoke(true); } catch (Exception e) { Log.i(REACT_MODULE, e.toString()); + errorCallback.invoke(true); } } diff --git a/index.android.d.ts b/index.android.d.ts index 46ca43a8..c447f55f 100644 --- a/index.android.d.ts +++ b/index.android.d.ts @@ -158,7 +158,7 @@ declare module 'react-native-google-fit' { isEnabled(callback: (isError: boolean, result: boolean) => void): void - openFit(): void + openFit(callback: (isError: boolean, result: boolean) => void): void observeSteps: (callback: (isError: boolean, result: any) => void) => void diff --git a/index.android.js b/index.android.js index 3247cad0..a3708b4e 100644 --- a/index.android.js +++ b/index.android.js @@ -443,8 +443,8 @@ class RNGoogleFit { ) } - openFit() { - googleFit.openFit() + openFit(callback) { + googleFit.openFit((msg) => callback(msg, false), res => callback(false,res)) } observeSteps = callback => {