Group channel: Advanced
This page explains the advanced features for group channels.
Send typing indicators to other members
If the startTyping
and endTyping
methods are called while the current user is typing a message in a group channel, the channelDidUpdateTypingStatus:
in the channel delegate will be invoked on all channel members' devices except the one that belongs to the current user.
Mark messages as delivered
To mark messages as delivered when a group channel member successfully receives a push notification for the message from APNs, the markAsDeliveredWithRemoteNotificationPayload:completionHandler:
method should be implemented in Notification Service Extension
.
When a message is delivered to an online group channel member, it is automatically marked as delivered and the other online members are notified of delivery receipt through the channelDidUpdateDeliveryReceipt:
method of SBDChannelDelegate
. However, when it is delivered to an offline member as a push notification, the message can be marked as delivered through the markAsDeliveredWithRemoteNotificiationPayload
method of SBDMain
, and other online members are notified of the delivery receipt through the channelDidUpdateDeliveryReceipt:
method.
Mark messages as read
To keep the most up-to-date and accurate read status of messages for all group channel members, the markAsRead()
method should be called every time one of the members reads messages by entering the channel from a channel list or bringing the opened channel view to the foreground.
If the current user opens a channel and the markAsReadAll()
is called, Sendbird server will update both the unread message count of the individual channel and the total unread message count of all the group channels joined by the user. Then the server triggers the channelDidUpdateReadReceipt:
method of the channel event delegate to notify the change of read status to all channel members' devices, except the one that is being used by the current user.
Note : When a channel member sends a message to the channel, Sendbird server updates the member's read receipt to the time when the message has sent. Meanwhile, the read receipts of other channel members can be updated when the
markAsRead()
method is called. If a new member joins the channel, the method works differently based on the value of thedisplay_past_message
property of your Sendbird application. If the property is set to YES, the new member’s read receipt will be updated to the sent time of the last message in the channel. If NO, it will be updated to 0.
Note: The
display_past_message
property determines whether to display past messages to newly joined members when they enter the channel. This property is also linked to theChat history
option, which can be adjusted in your dashboard under Settings > Chat > Channels > Group channels.
Retrieve number of members who haven’t received a message
You can retrieve the number of members who haven’t received a specific message in a group channel. If zero is returned, it means that the message has been delivered to all the other members.
Retrieve members who have read a message
Using the getReadMembersWithMessage:
method, you can view members who have read a specific message in a group channel. The method returns a list of channel members who have read the message by comparing the message’s creation time and the channel members’ read receipt. The list will exclude the current user and the message sender.
Note: Read receipt indicates the timestamp of the latest time when each user has read messages in the channel, in Unix milliseconds.
If you want to keep track of who has read a new message, we recommend to use the getReadMembersWithMessage:
in the channelDidUpdateReadReceipt:
of the channel event delegate. Then the client app will receive a callback from Sendbird server whenever a channel member reads a message. To do so, you should pass the new message object as an argument to a parameter in the getReadMembersWithMessage:
through the channelDidUpdateReadReceipt
.
Note: Using the
getUnreadMembersWithMessage:
method, you can also view members who have not read a specific message in a group channel, except the current user and the message sender. In the meantime, you can get information on each channel member's read receipt through thegetReadStatus
method.
Retrieve number of members who haven't read a message
Using the getReadReceiptOfMessage:
method, you can get the number of members who have not read a specific message in a group channel. To get the exact value, the channel should be updated first through the markAsRead
before calling the getReadReceiptOfMessage:
.
Retrieve the last message of a channel
You can retrieve the last message of a group channel.
Retrieve number of unread messages in a channel
You can retrieve the total number of the current user's unread messages in a group channel.
Retrieve number of unread messages in all channels
You can retrieve the total number of the current user's unread messages in all joined group channels.
Retrieve number of channels with unread messages
You can retrieve the total number of the current user's joined group channels which one or more unread messages.
Send an admin message
You can send admin messages to a group channel using Sendbird Dashboard or Chat Platform API. To send an admin message through your dashboard, go to the Chat > Group channels, select a group channel, find the message box below, click the Admin message tab, and then write your message in the box. An admin message is limited to 1,000 characters.
Unlike other types of messages, a push notification for an admin message is not available by default. If you want assistance on this, contact our sales team.
Add extra data to a message
You have the option to create further actions in a channel by using extra data in a message. You can add one or more key-values items to a message which you can save, update, or remove, when necessary. Based on those items, you can design and implement several different actions such as measuring user engagement within a chosen time limit through polls or counting how many times a message has been copied by members.
Note: For the quality of performance, every Sendbird application has its own limits to how many key-values items you can add to a single message, as well as the maximum number of values an item can have. If you would like more information on these limits, contact our sales team.
To get the key-values items of a message, read the message.metaArrays
.
The Chat SDK supports the URL link preview when a message text contains the URL of a web page.
Note: This feature is turned on by default for Sendbird applications. If this isn't available for your Sendbird application, contact our support team to enable the feature.
If a SBDBaseMessage
object includes a valid URL of a website, the object can contain SBDOGMetaData
, a class that holds the OG metadata such as title, URL, description, and default image of an OG object.
Note: Some websites don’t provide the OG metadata. In that case, even though the Open Graph protocol states them as requirements, all of the four properties can be null.
List of properties
Property name | Description |
---|---|
title | The title of the OG object as it should appear within the graph. The value can be null. |
url | The canonical URL of the object that can be used as its permanent ID in the graph. The value can be null. |
desc | The description of the object. The value can be null. |
defaultImage | An |
A SBDOGImage
, the image contained in a SBDOGMetaData
object, is a class that holds image-related data for the SBDOGImage
object. The SBDOGImage
class can also have its own optional structured properties of URL, secure URL, type, width, height, and alt.
Note: Except for width and height, other fields such as URL, secure URL, type, and alt can be null. If the target website doesn’t provide width and height data, the value of those two fields are set to 0.
List of properties
Property name | Description |
---|---|
url | The URL of an image object within the Open Graph. The value can be null. |
secureUrl | An alternative URL to use if the webpage requires |
type() | A media type or MIME type of this image. The value can be null. |
width() | The number of pixels horizontal. When the value is unavailable, this method returns 0. |
height() | The number of pixels vertical. When the value is unavailable, this method returns 0. |
alt() | The description of what is in the image, not a caption of the image. The alt attribute is designed to provide a fuller context of the |
If a user sends a message with a web page URL and the linked web page possesses Open Graph (OG) tags, or OG metadata, Sendbird server parses the message content, extracts the URL in the message, gets the OG metadata from it, and creates an OG metadata object for the message. Then message recipients will get the parsed message with its OG metadata through the didReceiveMessage:
method in the channel event delegate of the SDK. On the other hand, the message sender will do the same through the didUpdateMessage:
.
Displaying an OG metadata object is available for two subtypes of a SBDBaseMessage
: SBDUserMessage
and SBDAdminMessage
. If the content of either a SBDUserMessage
or SBDAdminMessage
object includes a web page URL containing OG metadata, the didReceiveMessage:
method returns SBDOGMetaData
and SBDOGImage
objects.
If Sendbird server doesn’t have cache memory of the OG metadata of the given URL, the SBDBaseMessage.ogMetaData
can be null due to the time it takes to fetch the OG metadata from a remote web page. In the meantime, the message text containing the URL will be delivered first to message recipients’ client app through the didReceiveMessage:
method. When the server completes fetching, the didUpdateMessage:
method will be called and the message with its SBDOGMetaData
object will be delivered to the recipients’ client app. However, if Sendbird server has already cached the OG metadata of the URL, the SBDBaseMessage.ogMetaData
returns the message and its SBDOGMetaData
object instantly and the didUpdateMessage:
method won’t be called.
Categorize channels by custom type
When creating a group channel, you can additionally specify a custom channel type to subclassify group channels. This custom type takes on the form of a NSString
, and can be useful in searching or filtering group channels.
The data
and customType
properties of a channel object allow you to append information to your channels. While both properties can be used flexibly, common examples for the customType
include categorizing group channels into School or Work.
To get a channel's custom type, read the groupChannel.customType
.
Categorize messages by custom type
When sending a message, you can additionally specify a custom message type to subclassify messages. This custom type takes on the form of a NSString
, and can be useful in searching or filtering messages.
The data
and customType
properties of a message object allow you to append information to your messages. While both properties can be used flexibly, common examples for the customType
include categorizing message groups into Notes or Contacts.
To embed a custom type into your message, assign a value to the customType
under the SBDUserMessageParams
or SBDFileMessageParams
object. Then, pass the specified object as an argument to the parameter in the sendUserMessageWithParams:completionHandler:
or sendFileMessageWithParams:completionHandler:
method.
To get a message's custom type, read the message.customType
.
Search channels by name, URL, or other filters
You can search for specific group channels by using several types of search filters within the SBDGroupChannelListQuery
and SBDPublicGroupChannelListQuery
classes.
SBDGroupChannelListQuery
A SBDGroupChannelListQuery
instance provides many types of search filters such as channelNameContainsFilter
and channelUrlsFilter
. You can use these filters to search for specific private group channels.
The sample code below shows the query instance, which returns a list of the current user's group channels that partially match the specified keyword in the channelNameContainsFilter
in the channels' name.
The following shows the query instance, which returns a list of the current user's group channels that partially match the specified keyword in the channelUrlsFilter
in the channels' URL.
The following table shows all supported filters for SBDGroupChannelListQuery
to search for specific channels you want to retrieve. You can use any filters in a similar fashion with the sample code above.
List of filters
Name | Filters |
---|---|
Group channels with one or more specified custom types. | |
Group channels with a custom type that starts with the specified value. | |
Group channels that contain the specified value in their names. | |
Group channels with one or more specified channel URLs. | |
Either super or nonsuper group channels. | |
Either public or private group channels. | |
Group channels with one or more unread messages. | |
Group channels with the specified state and operating behavior. | |
Group channels based on whether the user has accepted an invitation. | |
Group channels that contain members with one or more specified user IDs. | |
Group channels that include one or more members with the specified user IDs. | |
Group channels with members whose nicknames contain the specified value. | |
Group channels with metadata containing an item with the specified value as its key. This filter is effective only when the metadata are sorted in alphabetical order. |
SBDPublicGroupChannelListQuery
A SBDPublicGroupChannelListQuery
instance provides many types of search filters such as channelNameContainsFilter
and channelUrlsFilter
. You can use these filters to search for specific public group channels.
The sample code below shows the query instance, which returns a list of the current user's group channels that partially match the specified keyword in the channelNameContainsFilter
in the channels' name.
The following shows the query instance, which returns a list of the current user's group channels that partially match the specified keyword in the channelUrlsFilter
in the channels' URL.
The following table shows all supported filters for SBDPublicGroupChannelListQuery
to search for specific channels you want to retrieve. You can use any filters in a similar fashion with the sample code above.
List of filters
Name | Filters |
---|---|
Group channels with one or more specified custom types. | |
Group channels with a custom type that starts with the specified value. | |
Group channels that contain the specified value in their names. | |
Group channels with one or more specified channel URLs. | |
Either super or nonsuper group channels. | |
Group channels with one or more specified URLs. | |
Group channels with metadata containing an item with the specified value as its key. This filter is effective only when the metadata are sorted in alphabetical order. |
Search messages by keyword
Message search is a feature that retrieves a list of messages that contain a search query or a specified keyword.
Implement the SBDMessageSearchQuery
to search messages in your iOS client app. The query will retrieve a list of messages that contain a search term and meet the optional parameter values set in the SBDMessageSearchQueryBuilder
class.
Note: Puncutations and special characters are ignored while indexing, so unless they're being used for advanced search functionalities, they should be removed or replaced in the search term for best results.
You can create the query instance in two ways. First, you can do so with the default values.
Or, you can create an instance by changing those values to your preference.
The query will retrieve a list of matched messages. Calling the builder method again will return the next page of the results.
Use the hasNext
method to see if there is a next page.
Use the isLoading
method to see if the search results are loading.
Advanced search
Advanced search allows the SDK to create and support complicated search conditions, improving search results. Search functionalities such as wildcard, fuzzy search, logical operators, and synonym search are supported for the keyword
parameter. You can use these functionalities by setting advancedQuery
to true. See the advanced search section in our Platform API Docs for more information.
-
Wildcard: Include
?
or*
in search terms.?
matches a single character while*
can match zero or more characters. -
Fuzzy search: Add
~
at the end of search terms. Fuzzy search shows similar terms to the search term determined by a Levenshtein edit distance. If your search term is less than two characters, only exact matches are returned. If the search term has between three and five characters, only one character is edited. If the search term is longer than five characters, up to two characters are edited. -
Logical operators: Use
AND
andOR
to search for more than one term. The logical operators must be uppercase. You can also use parentheses to group multiple search terms or specify target fields. If you want to look for search terms in not only the content of the message but also specified target fields of the message, such as custom type or data, you can specify the field and search term as a key-value item.
SBDMessageSearchQueryBuilder
You can build the query class using the following parameters which allow you to add various search options.
Parameter name | Description |
---|---|
keyword | Type: NSString |
channelUrl | Type: NSString |
channelCustomType | Type: NSString |
limit | Type: NSInteger |
exactMatch | Type: BOOL |
advancedQuery | Type: BOOL |
messageTimestampFrom | Type: NSInteger |
messageTimestampTo | Type: NSInteger |
order | Type: SBDMessageSearchQueryOrder |
reverse | Type: BOOL |
Generate thumbnails of a file message
When sending an image file, you can determine whether to create thumbnails of the image, which you can fetch and render into your UI. You can specify up to 3 different dimensions to generate thumbnail images in, which can be useful for supporting various display densities.
Note: Supported file types are files whose media type is
image/*
orvideo/*
. The Chat SDK does not support creating thumbnails when sending a file message with a file URL.
The sendFileMessageWithParams:completionHandler:
method requires passing a SBDFileMessageParams
object as an argument to a parameter, containing a NSArray
of SBDThumbnailSize
objects which each specify the maximum values of width and height of a thumbnail image with its makeWithMaxCGSize:
or makeWithMaxWidth:maxHeight:
constructors. The completionHandler:
callback subsequently returns a NSArray
of SBDThumbnail
objects that each contain the URL of the generated thumbnail image file.
A thumbnail image is generated evenly to fit within the bounds of maxWidth
and maxHeight
, which are provided through the constructor. Note that if the original image is smaller than the specified dimensions, the thumbnail isn't resized. The url
returns the location of the generated thumbnail file within Sendbird server.
Track file upload progress using a handler
If needed, you can track the file upload progress by passing the progressHandler:
code block as an argument to a parameter when calling the sendFileMessageWithParams:progressHandler:completionHandler:
method.
Cancel an in-progress file upload
Using the cancelUploadingFileMessageWithRequestId:completionHandler:
method, you can cancel an in-progress file upload while it's not completed yet. If the function operates successfully, true is returned to the completionHandler:
.
Note: If you attempt to cancel the uploading after it is already completed, or canceled, or returned an error, the function returns NO.
This file encryption feature prevents users without access from opening and reading encrypted files that have been shared within a group of users. When this feature is turned on, all types of sent files and thumbnail images will be first uploaded to Sendbird server, and then encrypted by AES256
.
In a group channel, encrypted files and thumbnail images will be decrypted and accessed securely only by the members. Anyone outside of the channel and application will not have access to those files and thumbnail images. The following explains how this data security works and what to do at the SDK level to apply it to your client apps.
The Sendbird system enables secure encryption and decryption of files by generating and distributing an opaque and unique encryption key for each user. An encryption key is managed internally by the system, and is valid for 3 days. It is generated every time the user logs in to Sendbird server through the Chat SDK, which then gets delivered to the Chat SDK from the server.
When the Chat SDK requests an encrypted file by its URL, the parameter auth should be added to the URL to access the file, which is specified with an encryption key of the user such as ?auth=RW5jb2RlIHaXMgdGV4eA==
. With the specified key in the auth, Sendbird server first decrypts the file, then checks if the user is a member of the group channel, and finally, allows the user to access and open the file in the channel.
This can be easily done by retrieving the fileMessage.url
property, which returns the unique file URL containing the parameter auth with an encryption key of the current user.
Spam flood protection
This feature allows you to customize the number of messages a member can send in a group channel per second. By doing so, all excess messages will be deleted and only the number of messages allowed to be sent per member per second will be delivered. This feature protects your app from some members spamming others in the channel with the same messages.
Note: Our default system setting is 5 messages per second. This limit can be manually adjusted only from our side. Contact our sales team for more information.
Message auto-translation
It is possible for text messages to be sent in different languages through the Sendbird's auto-translation feature. When sending a text message, set a NSArray
of language codes to a SBDUserMessageParams
object and then pass the object as an argument to parameter in the sendUserMessageWithParams:completionHandler:
method to request translated messages in the corresponding languages.
Note: Message auto-translation is powered by Google Cloud Translation API recognition engine. Find language codes supported by the engine in the Miscellaneous page or visit the Language Support page in Google Cloud Translation.
You can retrieve translations of a text message using the userMessage.translations
property which has a NSArray
object containing the language codes and translations.
Message on-demand translation
Using the translateUserMessage:targetLanguages:completionHandler:
method, you can allow your users to translate text messages into other languages when needed.
Note: Message on-demand translation is powered by Google Cloud Translation API recognition engine. Find language codes supported by the engine in the Miscellaneous page or visit the Language Support page in Google Cloud Translation.
Based on this method, you can implement features such as real-time or instant translation to your app. You can also implement to only translate a selected message into preferred languages.