OvalMoney / react-native-fitness

A React Native module to interact with Apple Healthkit and Google Fit.
MIT License
344 stars 68 forks source link

Error screen on android #68

Open batical opened 4 years ago

batical commented 4 years ago

On iOS it is working fine without issue

on android, I can make it work

Capture d’écran 2020-09-01 à 16 41 01

React native : 0.62 "@ovalmoney/react-native-fitness": "^0.4.0",

I did this step (I think correctly) Get an OAuth 2.0 Client ID as explained at https://developers.google.com/fit/android/get-api-key

When I try to call isAuthorized, or requestPermission

Capture d’écran 2020-09-01 à 16 46 00

Any idea ?

GuleriaAshish commented 4 years ago

I got the same error and resolve it by using direct values for kind permission like this: const permissions = [ {kind: 0, access: 0}, {kind: 2, access: 0}, {kind: 0, access: 1}, {kind: 2, access: 1} ];

All the values that we can use are : export declare enum PermissionKind { Steps = 0, Distances = 1, Calories = 2, HeartRate = 3, Activity = 4, SleepAnalysis = 5, }

export declare enum PermissionAccess { Read = 0, Wrtie = 1, }

batical commented 4 years ago

@GuleriaAshish thanks. You made my morning.. and my day ... and my week 👍

GuleriaAshish commented 4 years ago

You welcome @batical ,

Are you currently working on it? Actually i am facing an issue that when i call getCalories it returns me an empty array. So have you face this thing too?

batical commented 4 years ago

I quickly test If it was not crashing. have to to more implementation and test on real device.

I am only using getSteps in my case. will come back after more test

GuleriaAshish commented 4 years ago

Have you get a proper result in case of using getSteps?

batical commented 4 years ago

I tested with a internal release on my staging app.

I use Huawei P20 for testing. I install google fit app. I add a activity with some steps and was able to fetch them in my app

PaLaMuNDeR commented 4 years ago

@batical @GuleriaAshish since you managed to run it on Android, can you see if I am missing something? It just shows the modal to choose account, but no option to choose permissions after that

https://github.com/OvalMoney/react-native-fitness/issues/48#issuecomment-688761194

GuleriaAshish commented 4 years ago

I got the same error and resolve it by using direct values for kind permission like this: const permissions = [ {kind: 0, access: 0}, {kind: 2, access: 0}, {kind: 0, access: 1}, {kind: 2, access: 1} ];

All the values that we can use are : export declare enum PermissionKind { Steps = 0, Distances = 1, Calories = 2, HeartRate = 3, Activity = 4, SleepAnalysis = 5, }

export declare enum PermissionAccess { Read = 0, Wrtie = 1, }

@PaLaMuNDeR, Please refer this solution of how to use permissions const.