OvalMoney / react-native-fitness

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

Sleep Analysis #42

Closed dmitov closed 4 years ago

dmitov commented 4 years ago

Hi there! I've been delaying to contribute to the repo for quite a time and just observed how it's going.

I like the simplicity very much and I hope to bring some to the table for you. This is my weekend's work and it works nice on iOS, will tackle the Android but I need some guidance. Perhaps @Francesco-Voto you can show me the path and I will walk the extra mile!

Have a nice week!

dmitov commented 4 years ago

@Francesco-Voto I tackled Android today and seems to work okay. I have no physical device to test it with actual data, but if you can give it a look - it would be great! The code is greatly inspired by the Google Fit SDK docs: https://developers.google.com/fit/scenarios/read-sleep-data

Francesco-Voto commented 4 years ago

Hi @dmitov Thank you for the PR. I am checking it in these days but it seems very good!

dmitov commented 4 years ago

Hi @Francesco-Voto,

Today I noticed a few flaws in the implementation for iOS, pushed a few commits and they should be resolved now. Let me know if it works for you

Francesco-Voto commented 4 years ago

Thank you! I will test it as soon as I have time

abeeralshaer commented 4 years ago

@dmitov Hi, Great work!. Actually while trying to use your branch I keep getting The user must be signed in to make this API call error. What would this be?

patrick-samy commented 3 years ago

Hi there! I'm able to getSteps(), but getting a crash when calling getSleepAnalysis() on Android at the moment.

Any ideas?

10-01 18:27:23.483 31539 31539 E AndroidRuntime: FATAL EXCEPTION: main
10-01 18:27:23.483 31539 31539 E AndroidRuntime: Process: com.span.app, PID: 31539
10-01 18:27:23.483 31539 31539 E AndroidRuntime: com.facebook.react.bridge.ObjectAlreadyConsumedException: Map already consumed
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at com.facebook.react.bridge.WritableNativeMap.putString(Native Method)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at com.ovalmoney.fitness.manager.Manager.processSleep(Manager.java:476)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at com.ovalmoney.fitness.manager.Manager.access$300(Manager.java:60)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at com.ovalmoney.fitness.manager.Manager$18.onSuccess(Manager.java:399)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at com.ovalmoney.fitness.manager.Manager$18.onSuccess(Manager.java:380)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at com.google.android.gms.tasks.zzm.run(com.google.android.gms:play-services-tasks@@17.0.2:4)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:938)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at com.google.android.gms.internal.tasks.zzb.dispatchMessage(com.google.android.gms:play-services-tasks@@17.0.2:6)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:223)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7656)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
10-01 18:27:23.483 31539 31539 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
marln94 commented 3 years ago

Hi, the same is happening to me. I can call the getSteps() function without any trouble, but when I call the getSleepAnalysis() or getHeartRate() functions I get the same error.

@patrick-samy did you find a way to handle this?

patrick-samy commented 3 years ago

I didn't unfortunately, ended up switching to rn-apple-healthkit.