NotificationService

Access and manage user-visible notifications.

By default, Trixnity manages its own notifications. It can be seen as some sort of notification center, where notifications can be listed, count and dismissed. Usually this would be kept in sync with the platform notifications. There are platforms, that do not support syncing a list of notifications. For this use case, it is possible to enable MatrixClientConfiguration.enableExternalNotifications and get notification updates via getAllUpdates.

Inheritors

Types

Link copied to clipboard
data class Notification(val event: ClientEvent<*>, val actions: Set<PushAction>)

Functions

Link copied to clipboard
abstract suspend fun dismiss(id: String)

Mark the notification as dismissed.

Link copied to clipboard
abstract suspend fun dismissAll()

Dismiss all notifications.

Link copied to clipboard
abstract fun getAll(): Flow<List<Flow<Notification?>>>

Get all notifications.

Link copied to clipboard
abstract fun getAllUpdates(): Flow<NotificationUpdate>

Get all notification updates. This returns an empty flow, when MatrixClientConfiguration.enableExternalNotifications is not enabled.

Link copied to clipboard
abstract fun getById(id: String): Flow<Notification?>

Notification by id, or null if not available.

Link copied to clipboard
abstract fun getCount(): Flow<Int>

Total notification count across all rooms.

abstract fun getCount(roomId: RoomId): Flow<Int>

Notification count for the given room.

Link copied to clipboard
abstract fun getNotifications(response: Sync.Response, decryptionTimeout: Duration = 5.seconds): Flow<NotificationService.Notification>
abstract fun getNotifications(decryptionTimeout: Duration = 5.seconds, syncResponseBufferSize: Int = 4): Flow<NotificationService.Notification>
Link copied to clipboard
abstract fun isUnread(roomId: RoomId): Flow<Boolean>

Returns true if the room is considered unread. This does not mean that there is any notification for the room. A room is considered unread, when the last read event is before Room.lastRelevantEventId or MarkedUnreadEventContent is set.

Link copied to clipboard
abstract suspend fun onPush(roomId: RoomId, eventId: EventId?): Boolean

Handle a push for a room/event.

Link copied to clipboard
abstract suspend fun processPending()

Process possibly pending notifications from sync or push if needed. This may suspend for a long time (e.g., when the network is not available but a sync is needed).