BaseChannel
open class BaseChannel: NSObject, Codable, Identifiable, Cacheable, Injectable
extension BaseChannel: Serializable
extension BaseChannel: Mappable
An object represents base class for channel
-
Identifier for the channel conforming to
Identifiable
Declaration
Swift
open var id: String
-
The channel URL.
Declaration
Swift
open internal(set) var channelURL: String = ""
-
The name of channel.
Declaration
Swift
open internal(set) var name: String = ""
-
The channel cover image URL.
Declaration
Swift
open internal(set) var coverURL: String?
-
User who creates the channel
Since
3.0.199Declaration
Swift
open internal(set) var creator: User?
-
The timestamp when the channel is created in seconds.
Declaration
Swift
open internal(set) var createdAt: Int64 = 0
-
The custom data of the channel.
Declaration
Swift
open internal(set) var data: String?
-
The custom type of the channel.
Declaration
Swift
open internal(set) var customType: String?
-
The flag for a frozen channel.
Since
3.0.89Declaration
Swift
open internal(set) var isFrozen: Bool = false
-
Represents the channel is ephemeral or not.
Since
3.0.90Declaration
Swift
open internal(set) var isEphemeral: Bool = false
-
A list of messageIds of pinned messages.
Note
Pin functionality inOpenChannel
will be supported starting from 4.20.0.Since
4.2.0Declaration
Swift
open internal(set) var pinnedMessageIds: [Int64]?
-
The message that was pinned the last.
Note
Pin functionality inOpenChannel
will be supported starting from 4.20.0.Since
4.2.0Declaration
Swift
open internal(set) var lastPinnedMessage: BaseMessage?
-
Gets the current user’s muted information in this channel.
Since
3.0.118Declaration
Swift
open func getMyMutedInfo(completionHandler: MuteInfoHandler?)
Parameters
completionHandler
The handler block to be executed.
-
Channel type
Declaration
Swift
open var channelType: ChannelType
-
Indicates possibility of outdated information
Declaration
Swift
open var isDirty: Bool = false
-
Checks the channel type is open channel or not.
Declaration
Swift
open func isOpenChannel() -> Bool
Return Value
Returns true when this is open channel.
-
Checks the channel type is group channel or not.
Declaration
Swift
open func isGroupChannel() -> Bool
Return Value
true
if when this is a group channel. -
Checks the channel type is feed channel or not.
Since
4.6.0Declaration
Swift
open func isFeedChannel() -> Bool
Return Value
true
if when this is a group channel. -
Timestamp of when the
MessageCollection
for this channel has been created.Since
4.6.0Declaration
Swift
public internal(set) var messageCollectionLastAccessedAt: Int64 = 0
-
Encodes this object.
Declaration
Swift
open func encode(to encoder: Encoder) throws
Parameters
encoder
Encoder
instance -
Default constructor.
Declaration
Swift
public required init(from decoder: Decoder) throws
Parameters
decoder
Decoder
instance -
Description
Declaration
Swift
open override var description: String
-
Compares this object with given other object.
Declaration
Swift
public override func isEqual(_ object: Any?) -> Bool
Parameters
object
Any
instanceReturn Value
true
if same otherwisefalse
-
Retrieves previous or next messages based on a specified timestamp in the channel.
Since
3.0.181Declaration
Swift
open func getMessagesByTimestamp( _ timestamp: Int64, params: MessageListParams, completionHandler: MessageListHandler? )
Parameters
timestamp
Specifies the timestamp to be the reference point for messages to retrieve, in Unix milliseconds format. Messages sent before or after the timestamp can be retrieved.
params
Contains a set of parameters you can set regarding the messages in the results.
completionHandler
The handler block to be executed. The
messages
is the messages of the channel. Theerror
indicates whether there is an error. If there is no error, the value is null. -
Retrieves previous or next messages based on their message ID in a specific channel.
Since
3.0.181Declaration
Swift
open func getMessagesByMessageId( _ messageId: Int64, params: MessageListParams, completionHandler: MessageListHandler? )
Parameters
messageId
Specifies the message ID to be the reference point for messages to retrieve. Messages sent before or after the message with the matching message ID can be retrieved.
params
Contains a set of parameters you can set regarding the messages in the results.
completionHandler
The handler block to be executed. The
messages
is the messages of the channel. Theerror
indicates whether there is an error. If there is no error, the value is null.
-
Sends a user message.
Declaration
Swift
open func sendUserMessage( _ message: String, completionHandler: UserMessageHandler? ) -> UserMessage
Parameters
message
The message text.
completionHandler
The handler block to execute.
userMessage
is a user message which is returned from the Sendbird server. The message has a message ID.Return Value
Returns a temporary user message being sent to the Sendbird server. The message has a request ID instead of a message ID. The request status of the message is pending. If you try to send a message with an invalid parameter, the returned message is a user message with no properties. You can perform a validation of pending message by checking for the existence of the request ID.
-
Sends a string message of params.
Declaration
Swift
open func sendUserMessage( params: UserMessageCreateParams, completionHandler: UserMessageHandler? ) -> UserMessage
Parameters
params
The instance of
UserMessageCreateParams
that can has parameters related with string message.completionHandler
The handler block to be executed after the message was sent. This block has no return value and takes two argument, one is a file message was sent and other is an error made when there is something wrong to message.
Return Value
Returns a temporary user message being sent to the Sendbird server. The message has a request ID instead of a message ID. The request status of the message is pending. If you try to send a message with an invalid parameter, the returned message is a user message with no properties. You can perform a validation of pending message by checking for the existence of the request ID..
-
Attempts to resend a failed user message received by the failure callback.
Only failed message MUST be passed, not a succeeded message or a pending message.
Since
3.0.141Declaration
Swift
open func resendUserMessage( _ message: UserMessage, completionHandler: UserMessageHandler? ) -> UserMessage
Parameters
message
A message to send. A failed message is passed to the callback when fails to send a message
completionHandler
The handler block to be executed after the message is sent. This block has no return value and takes two arguments. One is a user message. If the message is successfully sent, the complete message instance is delivered. If the message fails to be sent, a failed message based on the pending message is delivered. Another factor is errors. If the message fails to be sent, a message error is dispatched.
Return Value
Returns a temporary user message being sent to the Sendbird server.
-
Copies a user message to the target channel.
Note
Only accpets messages whosesendingStatus
is.succeeded
.Declaration
Swift
open func copyUserMessage( _ message: UserMessage, toTargetChannel targetChannel: BaseChannel, completionHandler: UserMessageHandler? ) -> UserMessage?
Parameters
message
User message object.
targetChannel
Target channel object.
completionHandler
The handler block to execute. The
userMessage
is a user message which is returned from the Sendbird server. The message has a message ID.Return Value
Returns the temporary user message with a request ID. It doesn’t have a message ID. If there is any error, nil could be returned.
-
Updates a user message. The text message, data, custom type from user message params can be updated.
Since
3.0.110Declaration
Swift
open func updateUserMessage( messageId: Int64, params: UserMessageUpdateParams, completionHandler: UserMessageHandler? )
Parameters
messageId
The message ID of the message to be updated.
params
UserMessageUpdateParams
with updating fields.completionHandler
The handler block to be executed after update. This block has no return value and takes two argument. the one is updated message type of UserMessage. the other is an error made when there is something wrong to process.
-
Requests to translate the text message into the target languages.
You can get a user message with the
translations
property after the request, but the request does not trigger an update event on the message and does not get the message bygetMessageChangeLogs(token:params:completionHandler:)
.A translation request can affect not only your message, but also other people’s messages.
Since
3.0.148Declaration
Swift
open func translateUserMessage( _ message: UserMessage, targetLanguages: [String], completionHandler: UserMessageHandler? )
Parameters
message
The string type of the message of the user message instance will be translated.
targetLanguages
The target languages that the message will be translated into. e.g. “en”, “es”, “ch”
completionHandler
The handler block to be executed after translation. This block has no return value and takes two arguments. One is a user message. If succeeded to translate text of the message, the message instance with translations is delivered. If failed to translate, nil is delivered. Another factor is an error. If failed to request, an error is dispatched.
-
Sends a file message with file or file URL of params without progress.
If the params has a binary file, it will upload data to Sendbird storage. If not, the params has a file url, it will send a message with file url.
Declaration
Swift
open func sendFileMessage( params: FileMessageCreateParams, completionHandler: FileMessageHandler? ) -> FileMessage?
Parameters
params
Instance of
FileMessageCreateParams
that can has parameters related with file.completionHandler
handler block to be executed after the message was sent. This block has no return value and takes two argument, one is a file message was sent and other is an error made when there is something wrong to message.
Return Value
Returns a temporary file message being sent to the Sendbird server. The message has a request ID instead of a message ID. The request status of the message is pending. If you try to send a message with an invalid parameter, the returned message is a file message with no properties. You can perform a validation of pending message by checking for the existence of the request ID.
-
Sends a file message with file or file URL of params without progress.
If the params has a binary file, it will upload data to Sendbird storage. If not, the params has a file url, it will send a message with file url.
Declaration
Swift
open func sendFileMessage( params: FileMessageCreateParams, progressHandler: MultiProgressHandler?, completionHandler: FileMessageHandler? ) -> FileMessage?
Parameters
params
Instance of
FileMessageCreateParams
that can has parameters related with file.progressHandler
progress handler
completionHandler
handler block to be executed after the message was sent. This block has no return value and takes two argument, one is a file message was sent and other is an error made when there is something wrong to message.
Return Value
Returns a temporary file message being sent to the Sendbird server. The message has a request ID instead of a message ID. The request status of the message is pending. If you try to send a message with an invalid parameter, the returned message is a user message with no properties. You can perform a validation of pending message by checking for the existence of the request ID.
-
Sends a file message with file or file URL of params with progress.
If the params has a binary file, it will upload data to Sendbird storage. If not, the params has a file url, it will send a message with file url.
Since
3.0.116
Declaration
Swift
open func sendFileMessages( params: [FileMessageCreateParams], progressHandler: MultiProgressHandler?, sentMessageHandler: FileMessageHandler?, completionHandler: SBErrorHandler? ) -> [FileMessage]
Parameters
params
The instance of
FileMessageCreateParams
that can has parameters related with file.progressHandler
The handler block to be used to monitor progression.
requestId
is a unique identifier for the message send request.bytesSent
is the number of bytes sent since this method was called.totalBytesSent
is the total number of bytes sent so far.totalBytesExpectedToSend
is the expected length of the body data. These parameters are the same to the declaration ofurlSession(_:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:)
.sentMessageHandler
The handler block to be executed after each message was sent. This block has no return value and takes two argument, one is a file message was sent and other is an error made when there is something wrong to message.
completionHandler
The handler block to be executed after every message was sent. This block has no return value and takes an error. If the sending message can’t start at all because of the connection issue, the error isn’t nil.
Return Value
Returns a temporary file message being sent to the Sendbird server. The message has a request ID instead of a message ID. The request status of the message is pending. If you try to send a message with an invalid parameter, the returned message is a user message with no properties. You can perform a validation of pending message by checking for the existence of the request ID.
-
Updates a file message. The data, custom type from file message params can be updated.
Since
3.0.110Declaration
Swift
open func updateFileMessage( messageId: Int64, params: FileMessageUpdateParams, completionHandler: FileMessageHandler? )
Parameters
messageId
The message ID of the message to be updated.
params
The file message params that has updating fields.
completionHandler
The handler block to be executed after update.
-
Attempts to resend a failed file message received by the failure callback.
Only failed message MUST be passed, not a succeeded message or a pending message. If the failed message has a file URL, it means the failed message was created after failure of sending a file message command. So the method retries to send a file message command. If the failed message does not have a file URL, it means the failed message was created from failure of uploading a binary data. So the method retries to upload a binary data frist.
Since
3.0.147Declaration
Swift
open func resendFileMessage( _ message: FileMessage, binaryData: Data?, completionHandler: FileMessageHandler? ) -> FileMessage?
Parameters
message
A message to send. A failed message is passed to the callback when fails to send a message
binaryData
Data to resend. If the failed message has a file URL, the method will not send binary data. If the failed message does not have a file URL, the method will send binary data first and send a file message command with file url.
completionHandler
Handler block to be executed after the message is sent. This block has no return value and takes two arguments. One is a file message. If the message is successfully sent, the complete message instance is delivered. If the message fails to be sent, a failed message based on the pending message is delivered except invalid parameter error. If failed because of invalid parameter, message is nil. Another factor is errors. If the message fails to be sent, a message error is dispatched.
Return Value
Returns a temporary file message being sent to the Sendbird server.
-
Attempts to resend a failed file message received by the failure callback.
Only failed message MUST be passed, not a succeeded message or a pending message. If the failed message has a file URL, it means the failed message was created after failure of sending a file message command. So the method retries to send a file message command. If the failed message does not have a file URL, it means the failed message was created from failure of uploading a binary data. So the method retries to upload a binary data frist.
Since
3.0.147Declaration
Swift
open func resendFileMessage( _ message: FileMessage, binaryData: Data?, progressHandler: MultiProgressHandler?, completionHandler: FileMessageHandler? ) -> FileMessage?
Parameters
message
A message to send. A failed message is passed to the callback when fails to send a message
binaryData
Data to resend. If the failed message has a file URL, the method will not send binary data. If the failed message does not have a file URL, the method will send binary data first and send a file message command with file url.
progressHandler
The handler block to be used to monitor progression.
requestId
is a unique identifier for the message send request.bytesSent
is the number of bytes sent since this method was called.totalBytesSent
is the total number of bytes sent so far.totalBytesExpectedToSend
is the expected length of the body data. These parameters are the same to the declaration ofurlSession(_:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:)
.completionHandler
The handler block to be executed after the message is sent. This block has no return value and takes two arguments. One is a file message. If the message is successfully sent, the complete message instance is delivered. If the message fails to be sent, a failed message based on the pending message is delivered except invalid parameter error. If failed because of invalid parameter, message is nil. Another factor is errors. If the message fails to be sent, a message error is dispatched.
Return Value
Returns a temporary file message being sent to the Sendbird server.
-
Copies a file message to the target channel.
Note
Only accpets messages whosesendingStatus
is.succeeded
.Declaration
Swift
open func copyFileMessage( _ message: FileMessage, toTargetChannel targetChannel: BaseChannel, completionHandler: FileMessageHandler? ) -> FileMessage?
Parameters
message
File message object.
targetChannel
Target channel object.
completionHandler
The handler block to execute. The
fileMessage
is a user message which is returned from the Sendbird server. The message has a message ID.Return Value
Returns the temporary file message with a request ID. It doesn’t have a message ID. If there is any error, nil could be returned.
-
Cancels the file message uploading.
Declaration
Swift
open class func cancelUploadingFileMessage( requestId: String, completionHandler: ((_ result: Bool, _ error: SBError?) -> Void)? )
Parameters
requestId
The request ID of the file message that is been uploading.
completionHandler
The handler block to execute. If the
result
istrue
, then the uploading task of therequestId
has been cancelled.
-
Deletes a message. The message’s sender has to be the current user.
Note
When using the moderation feature in ephemeral open channel, you should use this function that uses the
message
object, not the function that uses themessageId
.Declaration
Swift
open func deleteMessage(_ message: BaseMessage, completionHandler: SBErrorHandler?)
Parameters
message
The message to be deleted.
completionHandler
The handler block to execute.
-
Deletes a message. The message’s sender has to be the current user.
Note
When using the moderation feature in ephemeral open channel, you should use the
deleteMessage(:completionHandler:)
function that uses themessage
object, not the function that uses themessageId
.Since
3.0.179
Declaration
Swift
open func deleteMessage(messageId: Int64, completionHandler: SBErrorHandler?)
Parameters
messageId
The message ID to be deleted.
completionHandler
The handler block to execute.
-
Deletes a message. The message’s sender has to be the current user.
Note
When using the moderation feature in ephemeral open channel, you should use the
deleteMessage(:completionHandler:)
function that uses themessage
object, not the function that uses themessageId
.Since
4.22.0
Declaration
Swift
open func deleteMessage(messageId: Int64, hardDelete: Bool, completionHandler: SBErrorHandler?)
Parameters
messageId
The message ID to be deleted.
completionHandler
The handler block to execute.
hardDelete
Whether to hard delete the message. Enabling this option will delete messages from the database as well as their contents. It’s set to
false
by default.
-
Pins the message to the channel.
Note
Pin functionality inOpenChannel
will be supported starting from 4.20.0.Since
4.2.0Declaration
Swift
open func pinMessage(messageId: Int64, completionHandler: SBErrorHandler?)
Parameters
messageId
The message ID of the message to be pinned.
completionHandler
The handler block to be executed after pinning the message.
-
Unpins the message from the channel.
Note
Pin functionality inOpenChannel
will be supported starting from 4.20.0.Since
4.2.0Declaration
Swift
open func unpinMessage(messageId: Int64, completionHandler: SBErrorHandler?)
Parameters
messageId
The message ID of the message to be unpinned.
completionHandler
The handler block to be executed after unpinning the message.
-
Creates keys of meta array for the message.
Since
3.0.116Declaration
Swift
open func createMessageMetaArrayKeys( message: BaseMessage, keys: [String], completionHandler: BaseMessageHandler? )
Parameters
message
The message object. This method creates
keys
in it.keys
Keys of meta array.
completionHandler
The handler block to execute. The
message
is a base message object that has the keys for its meta array. -
Deletes keys from meta array of the message.
Since
3.0.116Declaration
Swift
open func deleteMessageMetaArrayKeys( message: BaseMessage, keys: [String], completionHandler: BaseMessageHandler? )
Parameters
message
The message object. This method deletes keys of meta array of it.
keys
Keys to be deleted.
completionHandler
The handler block to execute.
-
Adds meta array to the message.
Since
3.0.116
Note
use
addMessageMetaArrayValues(message:metaArrays:completionHandler:)
as possible.Declaration
Swift
open func addMessageMetaArrayValues( message: BaseMessage, keyValues: [String: [String]], completionHandler: BaseMessageHandler? )
Parameters
message
The message object. This method adds pairs of key and value to this message.
keyValues
Pairs of key-value to be added.
completionHandler
The handler block to execute.
-
Adds the array of meta array into the message.
Note
ThemetaArrays
are upserted into the message. If a key in the metaArrays is new, the key will be inserted with the value. If a key in the metaArrays is already created, the value of the messageMetaArray will be inserted so strings in the value MUST be new one.Since
3.0.148Declaration
Swift
open func addMessageMetaArrayValues( message: BaseMessage, metaArrays: [MessageMetaArray], completionHandler: BaseMessageHandler? )
Parameters
message
The message instance. The metaArrays will added into the message.
metaArrays
An array of message meta array will be added into the message. the string of the value in the metaArray MUST NOT exist with same key.
completionHandler
The handler block to execute after adding message meta arrays. The
message
of the handler is updated message. If failed to add message meta arrays, theerror
of the handler is not nil(null). -
Removes meta array from the message.
Since
3.0.116Note
useremoveMessageMetaArrayValues(message:metaArrays:completionHandler:)
as possible.Declaration
Swift
open func removeMessageMetaArrayValues( message: BaseMessage, keyValues: [String: [String]], completionHandler: BaseMessageHandler? )
-
Removes the array of meta array from the message.
Note
ThemetaArrays
are removed from the message. If a key in the metaArrays has an emtpy array of the value, the key will be removed. If not, the value of the messageMetaArray will be removed from the message.Note
The order of the meta array is guaranteed.Since
3.0.148Declaration
Swift
open func removeMessageMetaArrayValues( message: BaseMessage, metaArrays: [MessageMetaArray], completionHandler: BaseMessageHandler? )
Parameters
message
The message instance. The metaArrays will removed from the message.
metaArrays
An array of message meta array will be removed from the message. the string of the value in the metaArray MUST exist with same key.
completionHandler
The handler block to execute after removing message meta arrays. The
message
of the handler is removed message. If failed to remove message meta arrays, theerror
of the handler is not nil(null).
-
Creates the meta counters for the channel.
Declaration
Swift
open func createMetaCounters( _ metaCounters: [String: Int], completionHandler: MetaCountersHandler? )
Parameters
metaCounters
The meta counters to be set
completionHandler
The handler block to execute.
metaCounters
is the meta counters which are set on Sendbird server. -
Gets the meta counters with keys for the channel.
Declaration
Swift
open func getMetaCounters( keys: [String]?, completionHandler: MetaCountersHandler? )
Parameters
keys
The keys to get meta counters.
completionHandler
The handler block to execute.
metaCounters
is the meta counters which are set on Sendbird server. -
Gets all meta counters for the channel.
Declaration
Swift
open func getAllMetaCounters(completionHandler: MetaCountersHandler?)
Parameters
completionHandler
handler block to execute.
metaCounters
is the meta counters which are returned from Sendbird server. -
Updates the meta counters for the channel.
Declaration
Swift
open func updateMetaCounters( _ metaCounters: [String: Int], completionHandler: MetaCountersHandler? )
Parameters
metaCounters
The meta counters to be updated.
completionHandler
The handler block to execute.
metaCounters
is the meta counters which are updated on Sendbird server. -
Increases the meta counters for the channel.
Declaration
Swift
open func increaseMetaCounters( _ metaCounters: [String: Int], completionHandler: MetaCountersHandler? )
Parameters
metaCounters
The meta counters to be increased.
completionHandler
The handler block to execute.
metaCounters
is the meta counters which are increased on Sendbird server. -
Decreases the meta counters for the channel.
Declaration
Swift
open func decreaseMetaCounters( _ metaCounters: [String: Int], completionHandler: MetaCountersHandler? )
Parameters
metaCounters
The meta counters to be decreased.
completionHandler
The handler block to execute.
metaCounters
is the meta counters which are decreased on Sendbird server. -
Deletes the meta counters with key for the channel.
Declaration
Swift
open func deleteMetaCounters( key: String, completionHandler: SBErrorHandler? )
Parameters
key
The key to be deleted.
completionHandler
The handler block to execute.
-
Deletes all meta counters for the channel.
Declaration
Swift
open func deleteAllMetaCounters(completionHandler: SBErrorHandler?)
Parameters
completionHandler
The handler block to execute.
-
Creates the meta data for the channel.
Declaration
Swift
open func createMetaData( _ metaData: [String: String], completionHandler: MetaDataHandler? )
Parameters
metaData
The meta data to be set.
completionHandler
The handler block to execute.
metaData
is the meta data which are set on Sendbird server. -
Gets the meta data for the channel.
Declaration
Swift
open func getMetaData( keys: [String], completionHandler: MetaDataHandler? )
Parameters
keys
The keys to get meta data.
completionHandler
The handler block to execute.
metaData
is the meta data which are set on Sendbird server. -
Gets all meta data for the channel.
Declaration
Swift
open func getAllMetaData(completionHandler: MetaDataHandler?)
Parameters
completionHandler
The handler block to execute.
metaData
is the meta data which are set on Sendbird server. -
Updates the meta data for the channel.
Declaration
Swift
open func updateMetaData( _ metaData: [String: String], completionHandler: MetaDataHandler? )
Parameters
metaData
The meta data to be updated.
completionHandler
The handler block to execute.
metaData
is the meta counters which are updated on Sendbird server. -
Deletes meta data with key for the channel.
Declaration
Swift
open func deleteMetaData(key: String, completionHandler: SBErrorHandler?)
Parameters
key
The key to be deleted.
completionHandler
The handler block to execute.
-
Deletes all meta data for the channel.
Declaration
Swift
open func deleteAllMetaData(completionHandler: SBErrorHandler?)
Parameters
completionHandler
The handler block to execute.
-
Return cached channel meta data.
Since
3.0.216Declaration
Swift
open func getCachedMetaData() -> [String: String]
Return Value
Dictionary meta data.
-
Bans a user for seconds. Let a user out and prevent to join again.
If the user is already banned, duration will be updated from the time that was initialized.
Since
3.0.89Declaration
Swift
open func banUser( _ user: User, seconds: Int, description: String?, completionHandler: SBErrorHandler? )
Parameters
user
The user to be banned.
seconds
Seconds of ducation to be banned. Seconds should be larger than -1. If it is -1, user is banned forever. If it is 0, duration is set 10 years by default.
description
The reason why the user was banned.
completionHandler
The handler block to be executed after the user is banned. This block has no return value and takes an argument that is an error madewhen there is something wrong to ban.
-
Bans a user for seconds. Let a user out and prevent to join again. If the user is already banned, duration will be updated from the time that was initialized.
Since
3.0.89Declaration
Swift
open func banUser( userId: String, seconds: Int, description: String?, completionHandler: SBErrorHandler? )
Parameters
userId
The user ID to be banned.
seconds
Seconds of ducation to be banned. Seconds should be larger than -1. If it is -1, user is banned forever. If it is 0, duration is set 10 years by default.
description
The reason why the user was banned.
completionHandler
The handler block to be executed after the user is banned. This block has no return value and takes an argument that is an error made when there is something wrong to ban.
-
Removes ban for a user.
Since
3.0.89Declaration
Swift
open func unbanUser(_ user: User, completionHandler: SBErrorHandler?)
Parameters
user
The user to be removed ban.
completionHandler
The handler block to be executed after remove ban. This block has no return value and takes an argument that is an error made when there is something wrong to remove ban.
-
Removes ban for a user.
Since
3.0.89Declaration
Swift
open func unbanUser(userId: String, completionHandler: SBErrorHandler?)
Parameters
userId
The user ID to be removed ban.
completionHandler
The handler block to be executed after remove ban. This block has no return value and takes an argument that is an error made when there is something wrong to remove ban.
-
Reports a user in a channel of inappropriate activities.
Since
3.0.154Declaration
Swift
@available(*, deprecated, renamed: "reportUser(_:reportCategoryInfo:reportDescription:completionHandler:﹚", message: "This method is deprecated in 4.23.0. Retrieve report categories from `getReportCategoryInfoList(completionHandler:﹚` and use `reportUser(_:reportCategoryInfo:reportDescription:completionHandler:﹚` instead.") open func report( offendingUser: User, reportCategory: ReportCategory, reportDescription: String?, completionHandler: SBErrorHandler? )
Parameters
offendingUser
The user who is being reported.
reportCategory
The category in which the report is being submitted. Valid choices are
suspicious
,harassing
,spam
, andinappropriate
.reportDescription
An open ended description for why the report is being submitted.
completionHandler
The handler block to execute.
-
Reports current channel instance of inappropriate activities.
Since
3.0.154Declaration
Swift
@available(*, deprecated, renamed: "report(reportCategoryInfo:reportDescription:completionHandler:﹚", message: "This method is deprecated in 4.23.0. Retrieve report categories from `getReportCategoryInfoList(completionHandler:﹚` and use `report(reportCategoryInfo:reportDescription:completionHandler:﹚` instead.") open func report( category: ReportCategory, reportDescription: String?, completionHandler: SBErrorHandler? )
Parameters
category
The category in which the report is being submitted. Valid choices are
suspicious
,harassing
,spam
andinappropriate
.reportDescription
An open ended description for why the report is being submitted.
completionHandler
The handler block to execute.
-
Reports a malicious message in the channel
Since
3.0.154Declaration
Swift
@available(*, deprecated, renamed: "reportMessage(_:reportCategoryInfo:reportDescription:completionHandler:﹚", message: "This method is deprecated in 4.23.0. Retrieve report categories from `getReportCategoryInfoList(completionHandler:﹚` and use `reportMessage(_:reportCategoryInfo:reportDescription:completionHandler:﹚` instead.") open func report( message: BaseMessage, reportCategory: ReportCategory, reportDescription: String?, completionHandler: SBErrorHandler? )
Parameters
message
The message object which is being reported.
reportCategory
The category in which the report is being submitted. Valid choices are
suspicious
,harassing
,spam
andinappropriate
.reportDescription
An open ended description for why the report is being submitted.
completionHandler
The handler block to execute.
-
Reports a user in a channel of inappropriate activities.
Since
4.23.0Declaration
Swift
public func reportUser( _ offendingUser: User, reportCategoryInfo: ReportCategoryInfo, reportDescription: String?, completionHandler: SBErrorHandler? )
Parameters
offendingUser
The user who is being reported.
reportCategoryInfo
The
ReportCategoryInfo
in which the report is being submitted. It can be retrieved fromSendbirdChat.getReportCategoryInfoList
.reportDescription
An open ended description for why the report is being submitted.
completionHandler
The handler block to execute.
-
Reports current channel instance of inappropriate activities.
Since
4.23.0Declaration
Swift
public func report( reportCategoryInfo: ReportCategoryInfo, reportDescription: String?, completionHandler: SBErrorHandler? )
Parameters
reportCategoryInfo
The
ReportCategoryInfo
in which the report is being submitted. It can be retrieved fromSendbirdChat.getReportCategoryInfoList
.reportDescription
An open ended description for why the report is being submitted.
completionHandler
The handler block to execute.
-
Reports a malicious message in the channel
Since
4.23.0Declaration
Swift
public func reportMessage( _ message: BaseMessage, reportCategoryInfo: ReportCategoryInfo, reportDescription: String?, completionHandler: SBErrorHandler? )
Parameters
message
The message object which is being reported.
reportCategoryInfo
The
ReportCategoryInfo
in which the report is being submitted. It can be retrieved fromSendbirdChat.getReportCategoryInfoList
.reportDescription
An open ended description for why the report is being submitted.
completionHandler
The handler block to execute.
-
Mutes a user with additional options. Muted user cannot send any messages to the group channel.
Since
3.0.118Declaration
Swift
open func muteUser( _ user: User, seconds: Int, description: String?, completionHandler: SBErrorHandler? )
Parameters
user
The user to be muted.
seconds
The user cannot send any messages for this time.
description
The description that explains the reason why the user is muted.
completionHandler
The handler block to be executed after mute. This block has no return value and takes an argument that is an error made when there is something wrong to mute the user.
-
Mutes a user with additional options. Muted user cannot send any messages to the group channel.
Since
3.0.118Declaration
Swift
open func muteUser( userId: String, seconds: Int, description: String?, completionHandler: SBErrorHandler? )
Parameters
userId
The user ID to be muted.
seconds
The user cannot send any messages for this time.
description
The description that explains the reason why the user is muted.
completionHandler
The handler block to be executed after mute. This block has no return value and takes an argument that is an error made when there is something wrong to mute the user.
-
Unmutes a user.
Since
3.0.89Declaration
Swift
open func unmuteUser(userId: String, completionHandler: SBErrorHandler?)
Parameters
userId
The user ID to be turned off mute.
completionHandler
The handler block to be executed after turn off mute. This block has no return value and takes an argument that is an error made when there is something wrong to turn off mute.
-
Unmutes a user.
Since
3.0.89Declaration
Swift
open func unmuteUser(_ user: User, completionHandler: SBErrorHandler?)
Parameters
user
The user to be turned off mute.
completionHandler
The handler block to be executed after turn off mute. This block has no return value and takes an argument that is an error made when there is something wrong to turn off mute.
-
Adds operators to the channel.
Since
3.0.189Declaration
Swift
open func addOperators(userIds: [String], completionHandler: SBErrorHandler?)
Parameters
userIds
The user IDs to be operators.
completionHandler
The handler block to be executed.
-
Removes operators from the channel.
Since
3.0.189Declaration
Swift
open func removeOperators(userIds: [String], completionHandler: SBErrorHandler?)
Parameters
userIds
The user IDs to be removed from the operators.
completionHandler
The handler block to be executed.
-
Removes all operators from the channel.
Since
3.0.189Declaration
Swift
open func removeAllOperators(completionHandler: SBErrorHandler?)
Parameters
completionHandler
The handler block to be executed.
-
Updates a poll with params.
Since
4.5.0Declaration
Swift
open func updatePoll( pollId: Int64, params: PollUpdateParams, completionHandler: PollHandler? )
Parameters
pollId
ID of Poll to update
params
PollUpdateParams
instance.completionHandler
Completion block.
-
Deletes a poll.
Since
4.5.0Declaration
Swift
open func deletePoll( pollId: Int64, completionHandler: SBErrorHandler? )
Parameters
pollId
ID of Poll to remove
completionHandler
Completion block.
-
Closes a poll.
Since
4.5.0Declaration
Swift
open func closePoll( pollId: Int64, completionHandler: PollHandler? )
Parameters
pollId
ID of Poll to close
completionHandler
Completion block
-
Adds an option to a poll.
Since
4.5.0Declaration
Swift
open func addPollOption( pollId: Int64, optionText: String, completionHandler: PollHandler? )
Parameters
pollId
ID of Poll to add the poll option
optionText
Option text of the poll option
completionHandler
Completion block
-
Updates an option to a poll.
Since
4.5.0Declaration
Swift
open func updatePollOption( pollId: Int64, pollOptionId: Int64, optionText: String, completionHandler: PollHandler? )
Parameters
pollId
ID of poll to update the poll option
pollOptionId
ID of the poll option
optionText
Option text of the poll option
completionHandler
Completion block
-
Removes Poll option
Since
4.5.0Declaration
Swift
open func deletePollOption( pollId: Int64, pollOptionId: Int64, completionHandler: SBErrorHandler? )
Parameters
pollId
ID of the poll to delete poll option of
pollOptionId
poll option id to delete
completionHandler
Completion block
-
Votes poll
Since
4.5.0Declaration
Swift
open func votePoll( pollId: Int64, pollOptionIds: [Int64], completionHandler: PollVoteEventHandler )
Parameters
pollId
Poll ID to vote
pollOptionIds
List of poll option IDs to vote
completionHandler
Completion block
-
Adds a reaction to a message.
Messages with
sendingStatus
is not.success
will handler to return error.Note
This is idempotent.Note
This feature is only available in group channels.Since
3.0.169Declaration
Swift
open func addReaction( with message: BaseMessage, key: String, completionHandler: ReactionEventHandler? )
Parameters
message
The message object that the reaction will be added.
key
The reaction key to be added.
completionHandler
The handler block to be executed. If succeeded, the
reactionEvent
will have the information of the reaction. -
Deletes a reaction from a message.
Note
This is idempotent.Note
This feature is only available in group channels.Since
3.0.169Declaration
Swift
open func deleteReaction( with message: BaseMessage, key: String, completionHandler: ReactionEventHandler? )
Parameters
message
The message object that has the reaction key.
key
The reaction key to be deleted.
completionHandler
The handler block to be executed. If succeeded, the
reactionEvent
will have the information of the reaction.
-
Creates a query instance for banned user list of the channel.
Since
3.0.89Declaration
Swift
open func createBannedUserListQuery() -> BannedUserListQuery?
Return Value
The instance for the banned user list. Query only banned user list.
-
Creates a query instance for banned user list of the channel.
Since
4.0.1Declaration
Swift
open func createBannedUserListQuery( paramsBuilder: (BannedUserListQueryParams) -> Void ) -> BannedUserListQuery?
Parameters
paramsBuilder
The builder closure for setting
BannedUserListQueryParams
.Return Value
The instance for the banned user list. Query only banned user list.
-
Creates a query instance for banned user list of the channel.
Since
3.0.89Declaration
Swift
open func createBannedUserListQuery( params: BannedUserListQueryParams ) -> BannedUserListQuery?
Parameters
params
BannedUserListQueryParams
instance.Return Value
The instance for the banned user list. Query only banned user list.
-
Creates a query instance for banned user list of the channel.
Since
4.0.0Declaration
Swift
open class func createBannedUserListQuery( channelType: ChannelType, channelURL: String ) -> BannedUserListQuery
Parameters
channelType
The Type of channel, types of open channel or group channel.
channelURL
The channel URL.
Return Value
The instance for the banned user list. Query only banned user list.
-
Creates a query instance for banned user list of the channel.
Since
4.0.1Declaration
Swift
open class func createBannedUserListQuery( channelType: ChannelType, channelURL: String, paramsBuilder: (BannedUserListQueryParams) -> Void ) -> BannedUserListQuery
Parameters
channelType
The Type of channel, types of open channel or group channel.
channelURL
The channel URL.
paramsBuilder
The builder closure for setting
BannedUserListQueryParams
.Return Value
The instance for the banned user list. Query only banned user list.
-
Creates a query instance for banned user list of the channel.
Since
4.0.0Declaration
Swift
open class func createBannedUserListQuery( channelType: ChannelType, channelURL: String, params: BannedUserListQueryParams ) -> BannedUserListQuery
Parameters
channelType
The Type of channel, types of open channel or group channel.
channelURL
The channel URL.
params
BannedUserListQueryParams
instance.Return Value
The instance for the banned user list. Query only banned user list.
-
Creates a query instance for getting muted user list of the channel instance.
Declaration
Swift
open func createMutedUserListQuery() -> MutedUserListQuery?
Return Value
UserListQuery instance for the muted user list.
-
Creates a query instance for getting muted user list of the channel instance.
Declaration
Swift
open func createMutedUserListQuery(paramsBuilder: (MutedUserListQueryParams) -> Void) -> MutedUserListQuery?
Parameters
paramsBuilder
The builder closure for setting
MutedUserListQueryParams
.Return Value
UserListQuery instance for the muted user list.
-
Creates a query instance for getting muted user list of the channel instance.
Declaration
Swift
open func createMutedUserListQuery(params: MutedUserListQueryParams) -> MutedUserListQuery?
Parameters
params
The params object to change query condition.
Return Value
UserListQuery instance for the muted user list.
-
Creates a query instance for getting muted user list of the channel instance.
Since
4.0.0Declaration
Swift
open class func createMutedUserListQuery(channelType: ChannelType, channelURL: String) -> MutedUserListQuery
Parameters
channelType
The Type of channel, types of open channel or group channel.
channelURL
The channel URL.
Return Value
UserListQuery instance for the muted user list.
-
Creates a query instance for getting muted user list of the channel instance.
Since
4.0.0Declaration
Swift
open class func createMutedUserListQuery( channelType: ChannelType, channelURL: String, paramsBuilder: (MutedUserListQueryParams) -> Void ) -> MutedUserListQuery
Parameters
channelType
The Type of channel, types of open channel or group channel.
channelURL
The channel URL.
paramsBuilder
The builder closure for setting
MutedUserListQueryParams
.Return Value
UserListQuery instance for the muted user list.
-
Creates a query instance for getting muted user list of the channel instance.
Since
4.0.0Declaration
Swift
open class func createMutedUserListQuery(channelType: ChannelType, channelURL: String, params: MutedUserListQueryParams) -> MutedUserListQuery
Parameters
channelType
The Type of channel, types of open channel or group channel.
channelURL
The channel URL.
params
The params object to change query condition.
Return Value
UserListQuery instance for the muted user list.
-
Creates
PreviousMessageListQuery
instance for getting the previous messages list of the channel.Declaration
Swift
open func createPreviousMessageListQuery() -> PreviousMessageListQuery?
Return Value
Returns the message list of the channel.
-
Creates
PreviousMessageListQuery
instance for getting the previous messages list of the channel.Declaration
Swift
open func createPreviousMessageListQuery(paramsBuilder: (PreviousMessageListQueryParams) -> Void) -> PreviousMessageListQuery?
Parameters
paramsBuilder
The builder closure for setting
PreviousMessageListQueryParams
.Return Value
Returns the message list of the channel.
-
Creates
PreviousMessageListQuery
instance for getting the previous messages list of the channel.Declaration
Swift
open func createPreviousMessageListQuery(params: PreviousMessageListQueryParams) -> PreviousMessageListQuery?
Parameters
params
The params object to change query condition.
Return Value
Returns the message list of the channel.
-
Creates
PreviousMessageListQuery
instance for getting the previous messages list of the channel.Since
4.0.0Declaration
Swift
open class func createPreviousMessageListQuery( channelType: ChannelType, channelURL: String ) -> PreviousMessageListQuery
Parameters
channelType
channel type
channelURL
channel url
Return Value
Returns the message list of the channel.
-
Creates
PreviousMessageListQuery
instance for getting the previous messages list of the channel.Since
4.0.0Declaration
Swift
open class func createPreviousMessageListQuery( channelType: ChannelType, channelURL: String, paramsBuilder: (PreviousMessageListQueryParams) -> Void ) -> PreviousMessageListQuery
Parameters
channelType
channel type
channelURL
channel url
paramsBuilder
The builder closure for setting
ParticipantListQueryParams
.Return Value
Returns the message list of the channel.
-
Creates
PreviousMessageListQuery
instance for getting the previous messages list of the channel.Since
4.0.0Declaration
Swift
open class func createPreviousMessageListQuery( channelType: ChannelType, channelURL: String, params: PreviousMessageListQueryParams ) -> PreviousMessageListQuery
Parameters
channelType
channel type
channelURL
channel url
params
The params object to change query condition.
Return Value
Returns the message list of the channel.
-
Creates
OperatorListQuery
instance for getting operators in the channel.Since
3.0.94Declaration
Swift
open func createOperatorListQuery() -> OperatorListQuery?
Return Value
The operator list in the channel.
-
Creates
OperatorListQuery
instance for getting operators in the channel.Since
4.0.0Declaration
Swift
open func createOperatorListQuery(paramsBuilder: (OperatorListQueryParams) -> Void) -> OperatorListQuery?
Return Value
The operator list in the channel.
-
Creates
OperatorListQuery
instance for getting operators in the channel.Since
4.0.0Declaration
Swift
open func createOperatorListQuery(params: OperatorListQueryParams) -> OperatorListQuery?
Parameters
params
The params object to change query condition.
Return Value
The operator list in the channel.
-
Creates
OperatorListQuery
instance for getting operators in the channel.Since
4.0.0Declaration
Swift
open class func createOperatorListQuery( channelType: ChannelType, channelURL: String ) -> OperatorListQuery
Parameters
channelType
The Type of channel, types of open channel or group channel.
channelURL
The channel URL.
Return Value
The operator list in the channel.
-
Creates
OperatorListQuery
instance for getting operators in the channel.Since
4.0.0Declaration
Swift
open class func createOperatorListQuery( channelType: ChannelType, channelURL: String, paramsBuilder: (OperatorListQueryParams) -> Void ) -> OperatorListQuery
Parameters
channelType
The Type of channel, types of open channel or group channel.
channelURL
The channel URL.
paramsBuilder
The builder closure for setting
OperatorListQueryParams
.Return Value
The operator list in the channel.
-
Creates
OperatorListQuery
instance for getting operators in the channel.Since
4.0.0Declaration
Swift
open class func createOperatorListQuery( channelType: ChannelType, channelURL: String, params: OperatorListQueryParams ) -> OperatorListQuery
Parameters
channelType
The Type of channel, types of open channel or group channel.
channelURL
The channel URL.
params
The params object to change query condition.
Return Value
The operator list in the channel.
-
Creates
PollListQuery
instance for getting poll list in this channel.Since
4.5.0Declaration
Swift
open func createPollListQuery(limit: UInt = 20) -> PollListQuery?
Return Value
poll list query object.
-
Creates
PollVoterListQuery
instance for getting user list on given poll optionSince
4.5.0Declaration
Swift
open func createPollVoterListQuery( pollId: Int64, pollOptionId: Int64, limit: UInt = 20 ) -> PollVoterListQuery
Parameters
pollId
poll ID.
pollOptionId
poll option ID.
limit
voter list length
Return Value
poll voter list query object.
-
Creates
PollVoterListQuery
instance for getting user list on given poll optionSince
4.5.0Declaration
Swift
open func createPollVoterListQuery( pollId: Int64, pollOptionId: Int64 ) -> PollVoterListQuery
Parameters
pollId
poll ID.
pollOptionId
poll option ID.
Return Value
poll voter list query object.
-
Creates a
PinnedMessageListQuery
object that can be used to retrieve a list of pinned messages in the group channel.Note
Pin functionality inOpenChannel
will be supported starting from 4.20.0.Since
4.8.0Declaration
Swift
open func createPinnedMessageListQuery() -> PinnedMessageListQuery?
Return Value
A
PinnedMessageListQuery
object that can be used to retrieve a list of pinned messages. -
Creates a
PinnedMessageListQuery
object that can be used to retrieve a list of pinned messages in the group channel.Note
Pin functionality inOpenChannel
will be supported starting from 4.20.0.Since
4.8.0Declaration
Swift
open func createPinnedMessageListQuery(paramsBuilder: (PinnedMessageListQueryParams) -> Void) -> PinnedMessageListQuery?
Parameters
paramsBuilder
The builder closure for setting
PinnedMessageListQueryParams
.Return Value
A
PinnedMessageListQuery
object that can be used to retrieve a list of pinned messages. -
Creates a
PinnedMessageListQuery
object that can be used to retrieve a list of pinned messages in the group channel.Note
Pin functionality inOpenChannel
will be supported starting from 4.20.0.Since
4.8.0Declaration
Swift
open func createPinnedMessageListQuery( params: PinnedMessageListQueryParams ) -> PinnedMessageListQuery?
Parameters
params
A
PinnedMessageListQueryParams
object containing the parameters for the query.Return Value
A
PinnedMessageListQuery
object that can be used to retrieve a list of pinned messages.
-
Retrieves the changelogs since a specified token regarding the updated messages or the unique IDs of deleted messages in the channel.
Since
3.0.181Declaration
Swift
open func getMessageChangeLogs( token: String?, params: MessageChangeLogsParams = MessageChangeLogsParams(), completionHandler: MessageChangeLogHandler? )
Parameters
token
Specifies the token to be the reference point for the changelogs to retrieve.
params
Contains a set of parameters you can set regarding the messages in the results.
completionHandler
The handler block to execute. The
updatedMessages
retrieves the updated messages. ThedeletedMessageIds
retrieves the unique ID of deleted messages. ThehasMore
indicates whether there are more changelogs to be retrieved. Thetoken
retrieves the token of the last changelog in the results. Theerror
indicates whether there is an error. If there is no error, the value isnil
. -
Retrieves the changelogs since a specified timestamp, in Unix milliseconds format, regarding the updated messages or the unique IDs of deleted messages in the channel.
Since
3.0.181Declaration
Swift
open func getMessageChangeLogs( timestamp: Int64, params: MessageChangeLogsParams = MessageChangeLogsParams(), completionHandler: MessageChangeLogHandler? )
Parameters
timestamp
Specifies the timestamp to be the reference point for changelogs to retrieve, in Unix milliseconds format.
params
Contains a set of parameters you can set regarding the messages in the results.
completionHandler
The handler block to execute. The
updatedMessages
retrieves the updated messages. ThedeletedMessageIds
retrieves the unique ID of deleted messages. ThehasMore
indicates whether there are more changelogs to be retrieved. Thetoken
retrieves the token of the last changelog in the results. Theerror
indicates whether there is an error. If there is no error, the value isnil
. -
Retrieves the changelogs since a specified token regarding the updated polls or the unique IDs of deleted polls in the channel.
Since
4.5.0Declaration
Swift
open func getPollChangeLogs( token: String?, completionHandler: PollChangeLogsHandler? )
Parameters
token
Specifies the token to be the reference point for the changelogs to retrieve.
completionHandler
The handler block to execute. The
updatedPolls
retrieves the updated polls. ThedeletedPollIds
retrieves the unique ID of deleted polls. ThehasMore
indicates whether there are more changelogs to be retrieved. Thetoken
retrieves the token of the last changelog in the results. Theerror
indicates whether there is an error. If there is no error, the value isnil
. -
Retrieves the changelogs since a specified timestamp regarding the updated polls or the unique IDs of deleted polls in the channel.
Since
4.5.0Declaration
Swift
open func getPollChangeLogs( timestamp: Int64, completionHandler: PollChangeLogsHandler? )
Parameters
timestamp
Specifies the timestamp to be the reference point for changelogs to retrieve, in Unix milliseconds format.
completionHandler
The handler block to execute. The
updatedPolls
retrieves the updated polls. ThedeletedPollIds
retrieves the unique ID of deleted polls. ThehasMore
indicates whether there are more changelogs to be retrieved. Thetoken
retrieves the token of the last changelog in the results. Theerror
indicates whether there is an error. If there is no error, the value isnil
. -
Serializes this object into data
Declaration
Swift
open func serialize() -> Data?
Return Value
optional
Data
instance -
Deserializes and reconstructs the object
Declaration
Swift
open class func build(fromSerializedData data: Data?) -> Self?
Parameters
data
Data
instanceReturn Value
BaseChannel
if parameter is valid, otherwisenil
-
Initialize with json dictionary
Declaration
Swift
public func initWithDictionary(_ json: [String: Any]) -> Self?
-
Converts the object into dictionary
Declaration
Swift
public func _toDictionary() -> [String: Any]