Register token

TerraCore v0

Usage#

Register the device token (FCM token) to receive notifications. Supports both logged-in users and non-login users.

  • Logged-in users: The device token is tied to the user (userId, email, phone) to receive notifications for the corresponding user.
  • Non-login users: Register the device token to receive broadcast notifications.
coroutineScope.launch {
val deviceToken = callFunctionToGetFcmToken()
val result = TerraNotification.getInstance(terraApp).registerToken(deviceToken)
if (result.isSuccess()) {
// has registered successful
} else {
// handle error if needed
val errorMessage = result.exception().message
}
}