Count unread notifications
TerraCore v0
Usage#
Get the number of unread notification.
- Android
- iOS
coroutineScope.launch {
val deviceToken = callFunctionToGetFcmToken() // required for the non-login users
val result = TerraNotification.getInstance(terraApp).countUnreadNotifications(deviceToken)
if (result.isSuccess()) {
// update the UI or do something based on your business logic
} else {
// handle error if needed
val errorMessage = result.exception().message
}
}
let deviceToken = callFunctionToGetFcmToken() // required for the non-login users
TerraNotification.getInstance(by: app)?.countUnreadNotifications(
deviceToken: deviceToken,
completion: { result in
switch result {
case .success(let unreadCount):
// update the UI or do something based on your business logic
case .failure(let error):
// handle error if needed
}
}
)