Mobile SDKs
Send your users' phone health data to Sonar from your app, and read it back through the API.
Cloud providers such as Garmin connect to Sonar server to server. See Cloud Device Providers. Apple Health and Health Connect data live only on the phone, so an app on that phone has to read it and send it. The Sonar mobile SDK does that part.
The SDK only sends data. Your backend still creates users and reads their data through the API, and your API key never goes into the app.
Apple Health on iOS is available to every customer today. The Android SDK for Health Connect and Samsung Health is in early access.
What Is Available
| SDK | Package | Status |
|---|---|---|
| iOS (Swift) | SonarSDK, Swift package or CocoaPod from https://github.com/Sonar-Health/sonar-ios-sdk |
Available. Apple Health. iOS 16 or later, Xcode 26 or later |
| React Native | npm @sonarhealth/react-native-sdk |
Available for iOS. An Expo module (Expo SDK 54 or later) that wraps the iOS SDK |
| Android (Kotlin) | co.sonarhealth:sonar-sdk |
Early access. Health Connect and Samsung Health. Contact us to join |
The React Native package already builds for Android, so one codebase ships to both platforms. Android calls start working when the Android SDK leaves early access.
How Data Moves
Health records go straight from the SDK to Sonar. They do not pass through your backend. Your backend reads the processed results through the API and gives your app what it needs.
Mobile SDK architecture
Data flow- Your backend creates a Sonar user and, when the app asks, a single-use client token for that user.
- The SDK trades the client token for its own session and keeps that session fresh by itself.
- The user connects Apple Health. The SDK asks for permission, then sends recent days first and works back through the history period, two years by default. New data follows as the phone records it.
- Sonar processes the data and sends your backend a
subject.syncedwebhook. - Your backend reads the data with its API key.
See SDK Authentication, Supported Native Data, and SDK Synchronization for each step.
Who Does What
| Part | Does |
|---|---|
| Your mobile app | Configures the SDK, supplies client tokens, connects Apple Health, shows state and recovery steps |
| Your backend | Maps your signed-in user to a Sonar user, mints client tokens, receives webhooks, reads data through the API, sets consolidation |
| Sonar SDK | Asks for Health permission, reads and sends the data, keeps its session fresh |
| Sonar | Checks the app and user, normalizes and consolidates the data, serves the API |
Rules That Do Not Change
- Your API key stays on your backend.
- Each app installation has its own session.
- The operating system decides what the app may read. Users can grant only some types, or change their mind later. Your app has to handle both.
- The SDK and your API reads use the same Sonar user.
Good to Know
- Records deleted in Apple Health stay in Sonar. See Edits and Deletions.
- History goes back two years by default. You can choose from one month to five years. See History Period.
- iOS decides when background syncs run. A locked phone syncs after the next unlock.
- Edits in Apple Health to data from about the last week reach Sonar on their own. Older edits need
resync. - One phone per provider per user. If the same user connects Apple Health on a second phone, the newest phone takes over the connection and the older one stops sending.
Guides
- Mobile SDK Quickstart Backend, app, webhook, and API from start to finish
- iOS (Swift) Install, HealthKit setup, permissions, and background delivery
- React Native The Expo module and its config plugin
- SDK Authentication App registration, client tokens, sessions, and revocation
- SDK Interface Methods, state, results, and errors
- Supported Native Data What each platform reads and where it appears in the API
- SDK Synchronization What syncs when, edits, and when data is ready
- Provider Lifecycle Connect, permission changes, disconnect, and deletion
- Android (Kotlin) Early access: Health Connect and Samsung Health
- Cloud Device Providers The server-to-server path for cloud providers
Sonar