Notification
Notification is a special type of message that can be marked as read and queried. Currently, there are the following types of notifications:
NotificationType.subscription
:Subscription messageNotificationType.receivedFriendRequest
:Received friend requestNotificationType.sendFriendRequest
:Sent friend requestNotificationType.groupInvitation
:Group invitation messageNotificationType.provider
:Provider information
Subscribe
Subscribe a topic with topicId
, then you can receive notifications from that topic
.
try await ChatClient.default.subscribeTopic("topicId")
Receive
You can use the following method to subscribe notifications from the web3mq server.
ChatClient.default.notificationPublisher.sink { notifications in
// handle the notifications.
}
Read Status
Mark the notification as read.
ChatClient.default.updateNotificationStatus(notificationsIds, status: notificationStatus);
public enum NotificationStatus: String {
case received
case delivered
case read
}
Query
You can query all historical notifications by types and pagination.
Page<Notification> res = await client.queryNotifications(type, pagination);