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.
How are you planning to correctly adjust for the "timing dynamics between days". Is there a recommended solution that accounts for users sleep patterns including those who work shifts?
Don't forget to also de-duplicate the sleep data, third party apps can write additional sleep events potentially causing you to count more sleep that actually occurred!