Are you all sick of hearing about #applehealth yet? 😏 Today I had a couple of bug reports about an un-Apple Health-related crash, so I fixed that and sent out an update. But then it was back to the #sleep beta to debug some weird behaviour. #healthkit seems to be calling my app with “new data” over and over in the same minute and I can’t work out why. There’s no new data, either. When I go looking, I keep getting the same results over and over. It did that maybe a couple of times to me during testing, but I’ve seen some beta user logs with 20 or 30 calls exactly the same within a minute.
Sad to see how bad everyone’s data is, though. The main reason we put off this integration is because Apple Health doesn’t enforce any kind of data standards on the apps syncing to it, so the data I can get out tends to be low-quality, inconsistent, or both. I was hoping I was worrying about this more than necessary, but so far I’ve seen exactly the kind of bad data I expected in most cases.
Seems like #exist for #ios is updating #healthkit data in the background fairly regularly now. Fingers crossed it stays that way. After a little more testing to make sure the updating works well I’ll send it out to beta testers for the first round of #applehealth #sleep testing.
Left #exist for #ios alone over the weekend to see how well my #healthkit background updating would work. Today I had a look at the logs and it looks like all my data is updating without me opening the app, but not as often as I’d like. A change I made to stop duplicate updates occurring seems to be stopping a lot of non-duplicate updates getting through, so I had to try a different approach to de-duping the updates. I also noticed the app is getting a lot of “Network connection lost” errors when trying to send requests. Not sure what that’s about yet, as I haven’t been able to reproduce those errors to debug them. Still, getting closer and closer to releasing the #applehealth #sleep update to beta testers!
Aaaargh #applehealth! I’ve had the majority of the #sleep integration in #exist for #ios done for days now, but I’ve been fighting with getting the background observers working. I can’t watch the logs run in realtime, because I’m testing for #healthkit waking up my app in the background and telling it to send new data to Exist, and it won’t do it every time I add new data, because it wants to save battery. So I’m stuck adding data and waiting an hour or so before grabbing the log file to see if anything happened.
Fixed a bug in #exist for #ios today that was causing the app to crash when users turned on location tracking for the first time. Also continued some refactoring of #healthkit code in an effort to get background observers working for #applehealth #sleep and other HealthKit data. The idea is that iOS will notify my app when the user syncs new data to Apple Health, rather than me checking for it regularly. Still trying to get that working for activity data, but it seems to be working well for sleep so far.
Today I figured out a way to filter out duplicate #applehealth #sleep samples from the same app. I’m using Sleep++ (among others) for testing, and it’s duplicated all my sleep records for the past few days. Although the Apple Health app handles merging and de-duping data for the user, when a developer queries HealthKit, it just returns whatever it has, so you have to de-dupe it and all that good stuff yourself.
Making great strides today with #applehealth #sleep integration in #exist for #ios! Thanks to some help from @josh last night I got on the right track and today I figured out why I wasn’t adding up all the sleep data per day correctly. I fixed that, and also added some code to check what the longest period of “time in bed” is per day, so I can get bedtime and wake time from that record, in case there are multiple “time in bed” periods. I also added a check to make sure I only use data from one app per day, so if users record data from multiple apps for the same day I’ll just take the first app’s data and ignore the rest so they don’t get doubled-up data in Exist.