Overview
Make sure you have successfully integrated with a Junction Mobile SDK authentication scheme, before you proceed
to try out Junction Health SDK.
Mobile SDK Authentication
Learn how to authenticate your mobile app user with Junction Mobile SDK.
Apple HealthKit
Learn how to integrate with Apple HealthKit through Junction Mobile SDKs, available in
Native iOS, React Native and Flutter.
Android Health Connect
Learn how to integrate with Android Health Connect through Junction Mobile SDKs, available in
Native Android, React Native and Flutter.
Samsung Health
Learn how to integrate with Samsung Health through Junction Mobile SDKs, available in
Native Android and React Native.
Initial Setup
Review the Connection Policy options
Junction Health SDK has two Connection Policy options:- The default Auto Connect mode; and
- The opt-in Explicit Connect mode.
iOS apps: Configure your App Delegate
This section applies to:- 🔘 Native iOS apps
- 🔘 React Native iOS apps
- ❌ Flutter iOS apps (using Junction Flutter SDK 4.3.8 or later).
Junction Flutter SDK (4.3.8 and later) automatically integrates with your App Delegate through the Flutter Plugin machinery.
You need not manually edit your AppDelegate in Flutter iOS projects.
application(_:didFinishLaunchingWithOptions:) implementation, it must call Junction Health SDK
automaticConfiguration() synchronously before it returns.
Details
Details
Junction needs to register various handlers with the system frameworks like Apple HealthKit and BackgroundTasks. These frameworks
require said registrations to be completed before the “app finished launching” moment [1]
[2].For React Native apps, the AppDelegate is part of the template Swift or Objective-C code in your generated Xcode project.
Configure the Junction Health SDK
The Health SDK must be configured before use. The configuration is persistent, so you typically only need to do this a single time — immediately after a successful authentication with the Core SDK.For Android via Expo and React Native, the Health SDK API assumes Health Connect by default. To target Samsung Health, you must
pass
"samsung_health" to the provider argument when calling the API.Health Data Permissions
Ask user for health data permissions
Before the SDK can read any data, you need to ask the end user to grant health data permissions.For Android via Expo and React Native, the Health SDK API assumes Health Connect by default. To target Samsung Health, you must
pass
"samsung_health" to the provider argument when calling the API.Check if your app has asked for permissions before
You can check if your app has already asked the user at least once before, for permissions on a specificVitalResource.
Because Ask for Permission are gracefully ignored by the operating system beyond
the first time, checking before asking can help you skip the parts of your UX journey that only make sense to users
going through Ask for Permission for the first time.
The only exception to this behaviour is when a VitalResource pulls a new data type introduced in a new OS release.
In this scenario, calling Ask for Permission would result in an OS permission
prompt that asks for permissions on specifically those new data types.
If you wish
to provide a way for users to review their permission grants or denials, you can
inform them of the system app location where they can do so.
For Android via Expo and React Native, the Health SDK API assumes Health Connect by default. To target Samsung Health, you must
pass
"samsung_health" to the provider argument when calling the API.Check if a read permission was granted or denied (⚠️ Spoiler: You can’t)
Junction Health SDK allows you to ask for permission and check if your app has asked for permission before. However, Junction Health SDK cannot tell you:- Whether or not a user has granted or denied a read permission after the Ask for Permission has concluded.
- The state of a read permission at any exact moment — granted or denied.
To help prevent possible leaks of sensitive health information, your app cannot determine whether or not a user has granted permission to read data. If you are not given permission, it simply appears as if there is no data of the requested type in the HealthKit store. […]In other words, all third-party apps — including anyone using the Junction Health SDK — would:
- not be able to determine if a particular read permission has been granted or denied by the user;
- not be able to manage or review read permissions inside their app.
| Operating System | System App | Location |
|---|---|---|
| iOS 8.0 and above | Health app | Sharing > Apps and Services |
| iOS 15.0 and above | Settings app | Privacy & Security > Health |
| Android 13 or below | Health Connect app | Apps and Permissions |
| Android 14 and above | Settings app | Health Connect > Apps and Permissions |
When designing your user experience, assume you would have zero knowledge of
permission grants and denials after the user has gone through the Ask for Permission flow.
Automatic Data Sync
Junction Health SDK automates data sync for you on both Android and iOS. Please first consult the provider-specific guides for the requirements and setup instructions:iOS
| Sync is automatically… | |
|---|---|
| Activated on | All resource types you have asked permission for. |
| Triggered by | Two behaviours:
|
HealthKit change notification is an always-on behaviour.If you did not configure Apple HealthKit Background Delivery
as instructed, your app will not receive any HealthKit change notification while it is in background.
In turn, background sync would not occur.
Android
| Sync is automatically… | |
|---|---|
| Activated on | All resource types you have asked permission for. |
| Triggered by | Two mechanisms:
|
Sync On App Launch is an always-on behaviour. Background Sync is an opt-in behaviour.Please refer to the Android Health Connect guide or
the Samsung Health guide for the full context and required configuration
of these two behaviours.
Background Sync Frequency
Junction Health SDK schedules hourly background sync with Apple HealthKit, Android Health Connect and Samsung Health, provided that you have:- Configured Apple HealthKit Background Delivery as per instruction; and
- Configured Android Background Sync for the provider you are using — Health Connect or Samsung Health — and request user permissions (when necessary) as per instruction.
- Apple HealthKit: Sync Frequency
- Android Health Connect: Sync Frequency
- Samsung Health: Background Sync
Pausing Data Synchronization
You can pause and unpause data sync at any time, without having to sign-out the user from the Junction Mobile SDK. Note that pausing data sync does not reset the incremental sync progress and does not trigger a historical stage upon unpause. It only “freezes” the sync progress.For Android via Expo and React Native, the Health SDK API assumes Health Connect by default. To target Samsung Health, you must
pass
"samsung_health" to the provider argument when calling the API.Sync Status
You can observe thesyncStatus stream for continuous updates on the health data sync status.
Sync Progress Debugging UI (iOS only)
Sync Progress View on Native iOS
Sync Progress View on Native iOS
Junction Health SDK for iOS includes a If you are using UIKit, you can still access it through
ForEachVitalResource — a pre-baked SwiftUI View providing a
live-updated sync progress feed of all the VitalResources whose permissions have been asked for.You can use ForEachVitalResource() in any position which you would use ForEach. For example,
you can use it inside a Section of a List:Native iOS
UIHostingController:Native iOS
Sync Progress UI on Flutter / React Native
Sync Progress UI on Flutter / React Native
You can open the Apple HealthKit Sync Progress Inspector UI through a simple call:This Sync Progress Inspector UI provides a live-updated sync progress feed of all the VitalResources whose permissions have been asked for.
Note that it is currently a no-op on Android.
Persistent Logging (iOS only)
While Junction Dashboard provides a fairly comprehensive Mobile SDK Sync Progress view, the reporting mechanism can only include condensed and headline information in order to conserve network bandwidth usage. In order to troubleshoot data sync issues that are non-reproducible in controlled environments, the Health SDK supports opt-in Persistent Logging which would keep logs on disk across application launches.- A “Capture Sync Issues” switch, which toggles the SDK Persistent Logging.
- A “Share the Capture” button, which triggers the archive file generate-and-share flow.
- Instruct users to enable capturing; and
- In a few days time, share the capture (archive file) with you.
Junction may also require your support team’s help to obtain an archive file, in order to make progress on any non-reproducible issue reports.