React Native
Terra initialization
initTerra
devId: string
➡ The dev-id provided to you when signing up with Terra Developer Dashboard
referenceId: string
➡ A random string used to characterise a user on your server
returns
Promise<SuccessMessage>
Connection setup/magement
initConnection
Initialise a device connection. This function needs to be called once only when first creating the connection.
connection: Connections
➡ An ENUM from the Connections class signifying the connection you wish to initiate for.token: string
➡ A token used for authentication. Generate one here: https://docs.tryterra.co/reference/generate-authentication-token(Optional)
customPermissions: Set<CustomPermissions>
➡ This is defaulted as an emptySet
. If you want to make a more granular permissions request, you may send us a set ofCustomPermissions
startIntent: String?
➡ The path to the activity you wish to display when the user scans a freestylelibre from the background (i.e "co.tryterra.terra.example.MainActivity") Only valid for AndroidschedulerOn: Bool
➡ A boolean dictating if you wish turn on background delivery. Defaults to true. Please see Background Delivery section for setup.
returns
Promise<SuccessMessage>
getUserId
connection: Connections
➡ An ENUM from the Connections class signifying the connection get user_id for.
returns
Promise<GetUserId>
Data retrieval
DataMessage
getActivity
connection: Connections
➡ An ENUM from the Connections class signifying the connection you wish to initiate for.startDate: Date
➡ The beginning of the request in either Date or Unix TimestampendDate: Date
orendDate: Long
➡ The end of the request in either Date or Unix TimestamptoWebhook: Bool
➡ Whether or not to send data to your webhook. If false,DataMessage
on the returnedPromise
will contain the data in thedata
field.
returns
Promise<DataMessage>
getDaily
connection: Connections
➡ An ENUM from the Connections class signifying the connection you wish to initiate for.startDate: Date
➡ The beginning of the request in either Date or Unix TimestampendDate: Date
orendDate: Long
➡ The end of the request in either Date or Unix TimestamptoWebhook: Bool
➡ Whether or not to send data to your webhook. If false,DataMessage
on the returnedPromise
will contain the data in thedata
field.
returns
Promise<DataMessage>
getSleep
connection: Connections
➡ An ENUM from the Connections class signifying the connection you wish to initiate for.startDate: Date
➡ The beginning of the request in either Date or Unix TimestampendDate: Date
orendDate: Long
➡ The end of the request in either Date or Unix TimestamptoWebhook: Bool
➡ Whether or not to send data to your webhook. If false,DataMessage
on the returnedPromise
will contain the data in thedata
field.
returns
Promise<DataMessage>
getNutrition
connection: Connections
➡ An ENUM from the Connections class signifying the connection you wish to initiate for.startDate: Date
➡ The beginning of the request in either Date or Unix TimestampendDate: Date
orendDate: Long
➡ The end of the request in either Date or Unix TimestamptoWebhook: Bool
➡ Whether or not to send data to your webhook. If false,DataMessage
on the returnedPromise
will contain the data in thedata
field.
returns
Promise<DataMessage>
getAthlete
connection: Connections
➡ An ENUM from the Connections class signifying the connection you wish to initiate for.toWebhook: Bool
➡ Whether or not to send data to your webhook. If false,DataMessage
on the returnedPromise
will contain the data in thedata
field.
returns
Promise<DataMessage>
Writing data
postActivity
Writes activity data into Apple Health
connection: Connections
: The connection type (Connections_
) for which to post the data. For example,Connections_.APPLE
to write data to Apple Health.payload: TerraActivityPayload
: ATerraActivityPayload
object that contains the activity data you wish to post. This can include details like activity type, heart rate, distance, calories, and other metrics.
returns
A Promise
that resolves to a SuccessMessage
object indicating the success of the operation or rejects with an error.
Android-only methods
Fetches permissions granted by Health connect
grantedPermissions
**returns**
`
Promise<Array<String>>
`
Last updated
Was this helpful?