Apple Health Data Syncing
This article pertains to: Legacy API (V1) Inform (v2)
Apple has strict guidelines regarding battery consumption during use of an app, background processing, and sleep/locked states. In order to adhere to those guidelines, apps with the Validic Mobile Library embedded in it will update immediately when the app is open and in the foreground. If the app is running in the background or closed, the library will pull data about every hour.
The SDK will continue to collect new records in the background (as long as the app isn’t swiped away). However, it cannot continuously upload while in the background. The app gets about 30 seconds of background time to upload after being backgrounded. After that, the rest of the queue must wait until the app is in the foreground again. A couple queued records might get uploaded every time a new record is received in the background, but if there is a large queue it will not be fully processed until the app is foregrounded. Also, the phone must be unlocked. No data will be uploaded while the phone is locked.
Bringing the app back to the foreground does not immediately restart the queue processing. You may want to put [[VLDSession sharedInstance] processQueue]; in the AppDelegate's -applicationDidBecomeActive method, which would ensure that as soon as the app is foregrounded, uploads are resumed.
Also, if the iPhone is re-started Validic will receive HealthKit background updates without the user needing to manually open the app to re-enable subscriptions.
Many data types have their frequency of updates limited. For example, steps will only trigger a background update once per hour or so, no matter how often new data is available, as noted above.
No updates are received when the device is locked (this is a privacy feature). As soon as a device is unlocked, the background delivery observers will be called, as long as the minimum frequency time has passed.