Appearance
Minimal example
kotlin
// Application.onCreate
SensorBioSDK.initialize(this)
SensorBioSDK.environment = SB_Environment.PRODUCTION
SensorBioSDK.logHandler = { level, msg, args -> Log.println(level.toAndroid(), "SDK", msg ?: "") }
// A session that ended without the user asking is an event, not a supplied callback (§3.2.2).
// The SDK reports it; ending the session is yours to do:
SensorBioSDK.reauthenticationRequired.onEach { logoutAndShowLogin() }.launchIn(appScope)
// Register-or-login a user your app has already authenticated by its own means. Your backend mints
// a single-use sdk_token (see § 6) and hands it to the app; set it immediately before registering.
// The first call for a given userId registers, later calls sign the same user back in.
val creds = myBackend.mintSdkToken() // your exchange: returns organization_id + sdk_token
SensorBioSDK.sdkCredentials = SB_SDKCredentials(
organizationId = creds.organizationId,
sdkToken = creds.sdkToken,
)
when (val outcome = SensorBioSDK.registerUser(userId = myUserId)) {
is SB_RegisterUserOutcome.Success -> onSignedIn(outcome.session)
is SB_RegisterUserOutcome.Failed -> showError(outcome.code)
}
// In a ViewModel
viewModelScope.launch {
val dashboard = SensorBioSDK.fetchDashboardData(date = Instant.now(), tzOffset = tz, forceRemote = false)
_state.value = dashboard
}
SensorBioSDK.deviceFullyConfigured.onEach { onDeviceReady() }.launchIn(viewModelScope)
SensorBioSDK.deviceDisconnected.onEach { mac -> onDeviceLost(mac) }.launchIn(viewModelScope)See ExampleApp/ in the binary repo for a complete reference integration (register → pair → connect → dashboard). It is rebuilt against the published artifact as part of every release, so it always compiles against the surface documented here.