iOS
Important notes about background delivery on iOS
- For most data types the most possible frequency of updates is 1 hour.
- iOS can update data more frequently for some data types, for example, vo2 max.
- iOS may throttle the frequency of updates for background delivery depending on the app’s activity, battery state, etc.
- Background delivery is not possible while device is locked, so it will be executed only when the device is unlocked.
- iOS may stop background delivery if it detects that the app is not active for a long time.
- The feature is available starting with iOS 15.
Important: The SpikeSDK, along with any other HealthKit applications, cannot guarantee data synchronization on a fixed schedule. The hourly sync
interval serves as a guideline rather than a strict requirement enforced by iOS. Consequently, the actual synchronization frequency may vary,
occurring hourly, once per day, or during specific system-defined events, such as the conclusion of Sleep Mode or when the device begins charging.
Setup
Enable background delivery for app target
- Open XCode with your ios project
- Open the folder of your project in Xcode
- Select the project name in the left sidebar
- Open Signing & Capabilities section
- Select HealthKit background delivery under HealthKit section
Initialization at app startup
For background delivery to work properly, you need to initialize the SpikeSDK at app startup.AppDelegate.swift
:
Android
Important notes about background delivery on Android
- Background delivery is scheduled to run every hour, but ultimately Android decides when the delivery will be executed.
- Android may throttle the frequency of updates for background delivery depending on the app’s activity, battery state, etc.
- Android may stop background delivery if it detects that the app is not active for a long time.
- There is a limit of queries that can be done in Health Connect and it is different for foreground and background reads, so please request only essential data to be delivered in background. More information on (Health Connect documentation)
Important: The SpikeSDK, along with any other applications, cannot guarantee data synchronization on a fixed schedule. The hourly sync interval serves as a guideline rather than a strict requirement enforced by Android. Consequently, the actual synchronization frequency may vary, occurring hourly, once per day, or during specific system-defined events, such as the conclusion of Sleep Mode or when the device begins charging.
Setup
Add the following permission to yourAndroidManifest.xml
(for Android Health Connect):
Flutter specific
AddincludeBackgroundDelivery: true
when asking for Health Connect permissions:
enableBackgroundDelivery()
will overwrite previous configuration. So you have to call it with all the data types you want in one call.
To check current configuration call getBackgroundDeliveryConfig()
method.
To stop background delivery call disableBackgroundDelivery()
method.
Samsung Health
If Samsung Health Data is enabled before enabling background delivery,enableBackgroundDelivery
will automatically enable Samsung Health Data background delivery.
Samsung Health Data is available on Android devices only.