React Native

Terra initialization

initTerra

function initTerra(
  devID: string,
  referenceId: string,
): Promise<SuccessMessage>

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

function initConnection(
  connection: Connections,
  token: string,
  schedulerOn: boolean,
  customPermissions: CustomPermissions[] = [],
  startIntent: String | null = null
): Promise<SuccessMessage>

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. (E.g. Connections.APPLE_HEALTH, Connections.SAMSUNG , Connections.HEALTH_CONNECT)

  • 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 empty Set. If you want to make a more granular permissions request, you may send us a set of CustomPermissions

  • 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 Android

  • schedulerOn: 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 Timestamp

  • endDate: Date or endDate: Long ➡ The end of the request in either Date or Unix Timestamp

  • toWebhook: Bool ➡ Whether or not to send data to your webhook. If false, DataMessage on the returned Promise will contain the data in the data 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 Timestamp

  • endDate: Date or endDate: Long ➡ The end of the request in either Date or Unix Timestamp

  • toWebhook: Bool ➡ Whether or not to send data to your webhook. If false, DataMessage on the returned Promise will contain the data in the data field.

returns

  • Promise<DataMessage>

getBody

  • 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 Timestamp

  • endDate: Date or endDate: Long ➡ The end of the request in either Date or Unix Timestamp

  • toWebhook: Bool ➡ Whether or not to send data to your webhook. If false, DataMessage on the returned Promise will contain the data in the data 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 Timestamp

  • endDate: Date or endDate: Long ➡ The end of the request in either Date or Unix Timestamp

  • toWebhook: Bool ➡ Whether or not to send data to your webhook. If false, DataMessage on the returned Promise will contain the data in the data 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 Timestamp

  • endDate: Date or endDate: Long ➡ The end of the request in either Date or Unix Timestamp

  • toWebhook: Bool ➡ Whether or not to send data to your webhook. If false, DataMessage on the returned Promise will contain the data in the data 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 returned Promise will contain the data in the data 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: A TerraActivityPayload 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?