Unregister token

TerraCore v0

Usage#

Unregister a registered device token (FCM token) to receive notifications. Supports both logged-in users and non-login users.

  • Logged-in users: unregister the device token for current user. This function must be called before logging out. Otherwise, it will not be able to unsubscribe the device token for the logged-in user.
  • Non-login users: unregister the device token to stop receiving broadcast notifications for this device.
coroutineScope.launch {
val deviceToken = callFunctionToGetFcmToken()
val result = TerraNotification.getInstance(terraApp).unregisterToken(deviceToken)
if (result.isSuccess()) {
// has unregistered successful
} else {
// handle error if needed
val errorMessage = result.exception().message
}
}