Android
Setting up a connection
import co.tryterra.terrartandroid.TerraRT
import co.tryterra.terrartandroid.enums.Connections
import co.tryterra.terrartandroid.enums.DataTypes
import co.tryterra.terrartandroid.models.Update
// Assumes terraRT is already initialized and a device is connected
// (see the "Connect Wearable to SDK" guide)
val token = "yourStreamingToken" // Generated from your backend (see below)
val dataTypes = setOf(DataTypes.HEART_RATE, DataTypes.STEPS)
// Stream to BOTH your app AND Terra's websocket server
terraRT.startRealtime(
type = Connections.BLE,
dataTypes = dataTypes,
token = token,
updateHandler = { update ->
println("${update.type}: ${update.`val`} at ${update.ts}")
},
connectionCallback = { connected ->
println("Websocket connected: $connected")
}
)Generates a single-use token for a user (producer) connection. The id
identifies the user the token is scoped to — a v6 connection id or a v5
compatibility user UUID — and must belong to the authenticating
developer.
Authorizations
x-api-keystringRequired
Your API key for authentication
dev-idstringRequired
Your developer ID for authentication and tracking
Query parameters
idstringRequired
The id of the user to generate a token for.
Responses
200
Token generated.
application/json
tokenstringRequiredExample:
Single-use token to present in the IDENTIFY frame.
OTYwNWFi5ZWQMTAxMjg0Y2Qw.gzrPzZcS3Gy8QDOxbiPRwu30PTB3VxW0eE400
Missing id parameter, or missing/malformed authentication headers.
403
Invalid credentials, or the user does not belong to this developer.
500
Token generation failed.
post/auth/user
Last updated
Was this helpful?