Android (Kotlin)
Utility functions
isHealthConnectAvailable
Checks if Health Connect is available in a given application/activity context
context: Context
-> Activity context from android app to check if Health Connect is available for
openHealthConnect
Opens a health connect activity to overlay the current one, effectively redirecting the user into the Health Connect app
context: Context
: Activity context from android app
Initialization of Terra manager
instance
devId: String
➡ The developer identifier given to your after you signed up on TerrareferenceId: String?
➡ This is used by you to identify a user from your server to a terra usercontext: Context
➡ The context from the activity you are instantiating fromcompletion: @escaping (TerraManager, TerraError?) -> Void
➡ A callback function that is called when the TerraManager class is initialised. If an error has occurred in creation, then the completion will return aTerraError
class. Highly recommended to wait for this callback before proceeding
Terra manager Instance methods
Connection setup/management
allGivenPermissions
Retrieves all given permissions granted by health connect
completion (Set<String>) -> Unit
-> A set of given permissions to Health Connect
initConnection
Initialises a connection for Samsung Health/Google Fit
type: 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)
customReadTypes: 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
context: Context
➡ The context from the activity you are instantiating fromschedulerOn: Bool
➡ A boolean dictating if you wish turn on the schduler. Defaults to true.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")completion: @escaping (Bool, TerraError?) -> Void
➡ A callback with a boolean dictating if the initialisation succeeds.
getUserId
type: Connections
➡ The connection to retrieve the userId for
Data Retrieval
getActivity
type: Connections
➡ The Connection to get data fromstartDate: Date
orstartDate: Long
➡ 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`completion: (Bool, TerraActivityDataPayload?, TerraError?) -> Void ➡
Bool -> If the request was successful or not. If not, a TerraError instance will also be called
TerraActivityDataPayload? -> A payload for each data type. If toWebhook
is set to true, this returns a class with a property reference
referring to the payload reference sent to your webhook. If toWebhook
is set to false, then this returns the entire Terra normalised payload.
TerraError? -> Returned if any error occurred while retrieving data
getDaily
type: Connections
➡ The Connection to get data fromstartDate: Date
orstartDate: Long
➡ 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`completion: (Bool, TerraDailyDataPayload?, TerraError?) -> Void ➡
Bool -> If the request was successful or not. If not, a TerraError instance will also be called
TerraDailyDataPayload? -> A payload for each data type. If toWebhook
is set to true, this returns a class with a property reference
referring to the payload reference sent to your webhook. If toWebhook
is set to false, then this returns the entire Terra normalised payload.
TerraError? -> Returned if any error occurred while retrieving data
getSleep
type: Connections
➡ The Connection to get data fromstartDate: Date
orstartDate: Long
➡ 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`completion: (Bool, TerraSleepDataPayload?, TerraError?) -> Void ➡
Bool -> If the request was successful or not. If not, a TerraError instance will also be called
TerraSleepDataPayload? -> A payload for each data type. If toWebhook
is set to true, this returns a class with a property reference
referring to the payload reference sent to your webhook. If toWebhook
is set to false, then this returns the entire Terra normalised payload.
TerraError? -> Returned if any error occurred while retrieving data
getNutrition
type: Connections
➡ The Connection to get data fromstartDate: Date
orstartDate: Long
➡ 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`completion: (Bool, TerraNutritionDataPayload?, TerraError?) -> Void ➡
Bool -> If the request was successful or not. If not, a TerraError instance will also be called
TerraNutritionDataPayload? -> A payload for each data type. If toWebhook
is set to true, this returns a class with a property reference
referring to the payload reference sent to your webhook. If toWebhook
is set to false, then this returns the entire Terra normalised payload.
TerraError? -> Returned if any error occurred while retrieving data
Was this helpful?