Looking for help with our Apple HealthKit integration. We've successfully pulled steps, distance, active energy, glucose and heart rate. However, the data pulled for sleep duration is incorrect. Not sure what we're doing wrong.
Apple HealthKit Integration - Need help with sleep data
I am curious how your sleep data goes wrong. Would you mind to share the details? Does the discussion here help?
Best,
——
Ziqiao Chen
Worldwide Developer Relations.
The Past 3 days in our app showed the below: (7/16)- 7 hours (correct) (7/15) - 0 hours (incorrect, should be 8 hours) (7/14) - 15 hours (incorrect, should be 6 hours)
Found our issue! We were pulling time in bed instead of time actually asleep. Also, we were not adjusted properly for the timing dynamics between days where a user falls asleep before midnight vs after, and what day that sleep gets logged to. Hence the 15 hours on 7/14 was combining two nights of sleep. 7/15 was 0 hours because that was counted on 7/14 because the user fell asleep ~11pm on 7/14.