For the complete documentation index, see llms.txt. This page is also available as Markdown.
Connect data sources
Integration of Thryve SDK takes barely more than a few minutes to connect data sources up and running including native data sources.
Assuming you have set up your mobile app project as outlined and have added the Thryve SDK via dependency management or manually via framework files, you have everything to get going to get your users to connect their data source with your application.
Thryve Connection Widget makes it super simple to allow users to connect theiir data sources
All data connections and data stored at Thryve are always linked to a Thryve user. A Thryve user will be automatically created or an existing user will be retrieved when initializing the SDK.
Initialize the Thryve SDK
Create the ThryveSDK instance using getOrCreate and set up the ThryveSDKConfig object according to your needs. Initializing ThryveSDK will automatically create a new Thryve user or get an existing Thryve user based on endUserAlias.
There are two versions of ThryveSDK singleton initialization. Synchronous ThryveSDK.getOrCreate() and asynchronous await ThryveSDK.getOrCreate(). It is recommended to use async version when providing new config using ThryveSDK.getOrCreate(newConfig) to ensure ThryveSDK awaits user refresh safely
Parameter
Description
Mandatory
context
default Android context (only relevant for Android integration)
yes
authId
Credentials to authorize your app with the Thryve backend
yes
authSecret
Credentials to authorize your app with the Thryve backend
yes
ThryveSDK.getOrCreate throws a fatalError and an InitializationException on iOS and Android respectively, that must be handled in your code. Starting from Android SDK 5.0.5, InitializationException is handled internally in the SDK and communicated in a ThryveResponse to the host application via an optional callback
Create a Thryve user
The SDK will automatically take care of creating new users. It will also take care of managing existing users when endUserAlias is set. Therefore we highly encourage usage of endUserAlias as otherwise you will need to manually manage and set the endUserId for existing users. You can retrieve the endUserId of the current user using getEndUserId method.
Parameter
Description
Mandatory
endUserAlias
Unique identifier for your user that can be set optionally by you. Make sure to set a secure, non-predictable, unique identifier without personal identifiable information.
Maximum length is 80 characters, only alphanumeric characters and dash (-) are supported.
no
endUserId
Identifier used to authenticate your end-user with Thryve in network requests. Only set if you don't use the endUserAlias and want to initialize the SDK for an existing user.
no
With the introduction of Thryve SDK 5.0.0 former accessToken has been renamed to endUserId and partnerUserId has been renamed to endUserAlias for improved clarity. Functionality of parameters has not changed.
To avoid iOS SDK race conditions on endUserId refresh, please, use async version of ThryveSDK.getOrCreate() singleton init. Additionally, iOS SDK provides .endUserIdDidUpdate notification implementation to catch endUserId updates if needed: NotificationCenter.default.addObserver(forName: .endUserIdDidUpdate, ...)
Set user language
The configured language is used in the UI provided by Thryve, like the Thryve Connection Widget. If not manually set by your app, the SDK will use the language set on the device.
Parameter
Description
Mandatory
locale
Manually set the language code following ISO 639-1 to set the language that will be used on UI elements, e.g. the Thryve Widget. If empty the SDK will get the phone's language.
no
Display the Thryve Connection Widget
Thryve Connection Widget allows your end users to connect and disconnect all enabled data sources configured for your application without you needing to implement any views or logics.
Thryve Connection Widget makes it super simple to allow users to connect theiir data sources
The Thryve Connection Widget will be launched as a web-view and can be implemented within any view of your application by using ThryveDataSourceConnectionWidget.
Apple Health, Health Connect, and Samsung Health will be shown in the Thryve Connection Widget only if their respective modules are imported and the data source is available on the device.
Parameter
Description
Mandatory
redirectURL
To automatically redirect users after connection or disconnection of web data sources, we recommend configuring a deep link. The specified redirectURI should link the user to the screen where Thryve Connection Widget is embedded within your application
no. applicable to only native, react native and Flutter Android SDKs
import ThryveCore
import ThryveCommons
import ThryveObservability
import ThryveAppleHealth
import ThryveShenAI
import ThryveBLE
let appleHealthConfig = ThryveAppleHealthConfig(
dataTypes: ThryveAppleHealthDataType.allConnectorTypes,
enableBackgroundSync: true // `true` by default
),
let thryveSDKConfig = ThryveSDKConfig(
authId: "AUTH_ID",
authSecret: "AUTH_SECRET",
endUserAlias: "YOUR_UNIQUE_USER_IDENTIFIER",
endUserId: nil,
locale: "de",
configs: [appleHealthConfig, shenAIConfig, bleConfig],
observability: ObservabilityConfig(tracingEnabled: true, crashReportingEnabled: true)
)
await ThryveSDK.getOrCreate(thryveSDKConfig).getUserInformation()
// Optionally, when ThryveSDK is initialized from a non-async context (AppDelegate, legacy code, etc.),
// it is recommended to use the getOrCreate(...) callback to know when the SDK is ready.
ThryveSDK.getOrCreate(thryveSDKConfig) { initResult in
if initResult.successful {
Logger.i("ThryveSDK ready, you can start calling API methods")
} else if let error = initResult.errors?.first {
Logger.e("ThryveSDK init failed: \(error.errorMessage ?? "Unknown error")")
}
}
import com.thryve.sdk
import com.thryve.sdk.commons
import com.thryve.sdk.healthConnect
import com.thryve.sdk.samsungHealth
import com.thryve.sdk.shenAI
import com.thryve.sdk.ble
val healthConnectConfig = ThryveHealthConnectConfig(
dataTypes = ThryveHealthConnectDataType.entries.toList(),
enableBackgroundSync = true,
enableReadHealthDataHistory = true
)
val samsungHealthConfig = ThryveSamsungHealthConfig(
dataTypes = ThryveSamsungHealthDataType.entries.toList(),
enableBackgroundSync = true
)
val shenAIConfig = ThryveShenAIConfig(
apiKey = "SHEN_AI_API_KEY",
eventsListener = object : ThryveShenAIEventListener {
override fun onEvent(event: ThryveShenAIEvent) {
when (event) {
ThryveShenAIEvent.MEASUREMENT_FINISHED -> { /* Shen AI measurement has finished and is about to be uploaded */}
ThryveShenAIEvent.MEASUREMENT_FAILED -> { /* Shen AI measurement has failed - handle failure */}
ThryveShenAIEvent.DATA_UPLOAD_FINISHED -> { /* Shen AI has finished uploading data */}
ThryveShenAIEvent.DATA_UPLOAD_FAILED -> { /* Shen AI has failed uploading data */}
ThryveShenAIEvent.USER_SUMMARY_FINISHED -> { /* The Shen AI flow has been completed */ }
}
}
}
)
val thryveSDKConfig = ThryveSDKConfig(
authId = "ASSIGNED_AUTH_ID",
authSecret = "ASSIGNED_AUTH_SECRET",
endUserAlias = "XXXXXXXXXXX",
endUserId = null,
locale = "de",
healthConnectConfig = healthConnectConfig,
samsungHealthConfig = samsungHealthConfig,
shenAIConfig = shenAIConfig,
bleConfig = bleConfig
)
val thryveSDK = ThryveSDK.getOrCreate(thryveSDKConfig, context)
/**Android SDK 5.0.5 introduced an optional callback to communicate the status
of internal processes of getOrCreate. ThryveSDK instance can now be created
with a callback as shown in the sample code below.
**/
val thryveSDK = ThryveSDK.getOrCreate(thryveSDKConfig, context) { thryveResponse ->
if(thryveResponse.successful){
//ThyveSDK initialization processes completed successfully
} else {
// ThryveSDK initalization process failed. process the ThryveErrors for the specific reason.
thryveResponse.errors.map { thryveError -> Logger.e(TAG){" getOrCreate ThryveError in onCreate function $thryveError"} }
}
}