Apple Health, Health Connect & Samsung Health
Once a user connects Apple Health, Health Connect, or Samsung Health, the Thryve SDK can retrieve and sync data from these native sources either automatically or manually.
We generally recommend manually synchronizing connected native data sources whenever your app comes to the foreground to ensure all data is up-to-date, as automatic background data synchronization is highly dependent on the operating system and its resource and battery management, allowing for regular synchronizations.
SDK Module Configuration
When using Apple Health, Health Connect & Samsung Health, you will need the optional SDK modules Apple Health, Health Connect or Samsung Health. Make sure to initialize the corresponding configurations ThryveAppleHealthConfig, ThryveHealthConnectConfig and ThryveSamsungHealthConfig for correct functionality.
configs
List of ThryveSDKModulesConfig for imported SDK modules.
yes
When using the Apple Health module, make sure to define the data types in the ThryveAppleHealthConfig . This is only relevant for iOS integration.
dataTypes
The Apple Health data types Set<ThryveAppleHealthDataType> required by your app. Ensure to limit types to data described in your data privacy policy. Always ensure the configured dataTypes are consistent across your application. Please refer to this document to understand the data types.
yes
enableBackgroundSync
Configures background data synchronization on SDK initialization (retrieving data when your app is closed or idle). Requires Background Delivery to be enabled for the HealthKit Capability.
no
When using the Health Connect module, make sure to define the data types in the ThryveHealthConnectConnectorConfig . This is only relevant for Android integration
dataTypes
Health Connect data types required by your app. Ensure to limit types to data described in your data privacy policy. Always ensure the configured dataTypes are consistent across your application. Please refer to this document to understand the data types.
no, defaults to all supported data types
enableBackgroundSync
Will request background data sync permissions. If permissions are granted, background tasks using WorkManager will be scheduled by the Thryve SDK.
no, defaults to true
enableReadHealthDataHistory
Will request historical data sync permissions. If permissions are granted, timeframes older than 30 days can be requested when using manual data synchronization methods.
no, defaults to true
When using the Samsung Health module, make sure to define the data types in the ThryveSamsungHealthConfig . This is only relevant for Android integration
dataTypes
The Samsung Health data types required by your app. Please refer to this document to understand the data types. Ensure to limit types to data described in your data privacy policy. Always ensure the configured dataTypes are consistent across your application.
no, defaults to all supported data types
enableBackgroundSync
Schedules background tasks using WorkManager for data synchronization when app is closed or idle.
no, defaults to true
Automatic Background Data Synchronization
We utilize different technologies for automatic background data retrieval on iOS and Android. On iOS, the Thryve SDK employs HealthKit’s native background synchronization API. For Android, synchronization is scheduled and managed via WorkManager.
The availability of background data synchronizations is configurable for Apple Health, Samsung Health and Health Connect data sources in the corresponding config objects.
Background data synchronization is enabled in ThryveAppleHealthConfig, like on the other native data sources.
let appleHealthConfig = ThryveAppleHealthConfig(
dataTypes: ThryveAppleHealthDataType.allConnectorTypes,
enableBackgroundSync: true
)The Thryve SDK then registers for HealthKit background delivery on your behalf, and syncs whenever Apple Health records new data while your app is in the background. Pass the config when you initialize the SDK, in didFinishLaunchingWithOptions. Apple requires an app to register for background delivery within the first seconds after launch, so initializing the SDK later means updates are missed until the next launch.
To enable background data synchronization (retrieving data when your app is closed or idle) in native Android, using Kotlin, enable background sync in the ThryveHealthConnectConfig .
val healthConnectConfig = ThryveHealthConnectConfig(
dataTypes = ThryveHealthConnectDataType.entries.toList(),
enableBackgroundSync = true,
enableReadHealthDataHistory = true
) To enable background data synchronization (retrieving data when your app is closed or idle) in native Android, using Kotlin, enable background sync in the ThryveSamsungHealthConfig .
val samsungHealthConfig = ThryveSamsungHealthConfig(
dataTypes = ThryveSamsungHealthDataType.entries.toList(),
enableBackgroundSync = true
)In React Native, using javascript or Typescript, enable enableBackgroundSync sync in your configuration
The background data sychronization in the Flutter SDK is enabled in the ThryveSDKConfig during initialization. Check the Flutter SDK initialization section
Manual Data Synchronization
Manual data synchronization is recommended to ensure all recent data is available when the user opens your app. Therefore, we recommend using synchronize whenever your app moves to the foreground.
synchronize will ensure that both epoch and daily data added since the last data synchronization will be fetched from Apple Health, Health Connect, or Samsung Health. The initial execution of synchronize will fetch all data for today.
Historic data backfill
To access data predating the initial synchronization, the Thryve SDK provides methods for backfilling historical data. These methods allow synchronization of epoch and daily data within a specified timeframe.
dataSource
The data source to synchronize data from. iOS defaults to .apple
yes, on Android. no, on iOS
dataTypes
The data types to synchronize. It defaults to the data types defined in the data source config.
no
startDate
The date to start data retrieval and synchronization from. It is applicable only to the backfiill functions
yes
endDate
The date to end data retrieval and synchronization on. It defaults to today and applicable only to the backfiill functions.
no
Last updated

