Notification channel
There are two different views when rendering notification channels: Feed and Chat. Feed view shows all notifications in a list form while Chat view shows notifications in the form of a user-to-user group channel.
Feed vs. Chat
The following table lists the difference between Feed view and Chat view.
Feed | Chat | |
---|---|---|
UI | A list view that contains a new notification badge. | A channel view that contains a channel image and timestamp for each notification. |
Order of notifications | The most recent notification is displayed at the top. | The most recent notification is displayed at the bottom. |
Shown in channel list view | No | Yes, it's included in the channel list view along with other group channels. |
Feed view
The following items are key elements of SBUFeedNotificationChannelViewController
that are used to create a Feed view of the notification channel.
Initialize
You can start building a new Feed view through the SBUFeedNotificationChannelViewController
class by following the code below. Once the view is created, display the channel anywhere you want in your app. The channel URL of the feed notification channel can be found on Sendbird Dashboard under Notifications > Channels.
If you already have an exisiting FeedNotificationChannelViewController
, you need to update channel information before displaying the Feed view.
Module components
In the SBUFeedNotificationChannelViewController
class, SBUFeedNotificationChannelModule
and its components are used to display the Feed view. The module is composed of two components: headerComponent
and listComponent
.
headerComponent
The headerComponent
shows the title of the notification channel.
listComponent
The listComponent
shows a list of all notifications sent to the user.
Configure new notification badge
A green badge appears above the notification bubble when the current user receives a new notification in the Feed view. This badge is displayed based on the Feed's last read time value at the time of view creation. However, this time value remains the same while the Feed view is in the foreground, which prevents the badge from disappearing even if the user's already seen the notification. If you want to update the last read time value, see the code below. You can also call the updateLastSeenAt(_:)
method in SBUFeedNotificationChannelViewModel
instead.
Refresh notification collections
If you've authenticated to the Sendbird server by calling SendbirdUI.authenticateFeed(completionHandler:)
, there's no WebSocket connection between the UIKit and the Sendbird server. Due to the lack of connection, the UIKit can't receive real-time events to notify the user with updated information about the feed channel.
The UIKit will automatically refresh the notification collections when the client app is brought to foreground or when the device's network connection has changed. In the case that the collection information is received as a push notification from the client app, you can refresh the content of all valid notification collections.
Note:
NotificationCollection
is valid only if theisLive
flag is set totrue
.
Chat view
The following items are key elements of SBUChatNotificationChannelViewController
that are used to create a Chat view of the notification channel.
Initialize
Before creating the Chat view, implement the code below if you're already using a channel view in your app with standard modal and navigation. The channel URL of the chat notification channel can be found on Sendbird Dashboard under Notifications > Channels.
If you're currently using Chat UIKit for iOS features with a specific root view controller, implement the code below.
If you're using the channel view differently in your app than the cases mentioned above, then you need to find the existing ChatChannelViewController
object and display the view in your app. You need to also update channel information before displaying the Chat view if you already have an exisiting ChatNotificationChannelViewController
,
Module components
In the SBUChatNotificationChannelViewController
class, SBUChatNotificationChannelModule
and its components are used to display the Chat view. The module is composed of two components: headerComponent
and listComponent
.
headerComponent
The headerComponent
shows the channel title, channel image, and a back button that takes the user to the previous view.
listComponent
The listComponent
shows a list of all notifications.