GroupChannel

open class GroupChannel: BaseChannel, SortableElement

The GroupChannel class represents a group channel which is a private chat.

The user who wants to join the group channel has to be invited by another user who is already joined the channel. This class is derived from BaseChannel. If the BaseChannelDelegate is added, the user will automatically receive all messages from the group channels where the user belongs after connection. The GroupChannel provides the features of general messaging apps.

  • Typing indicator.
  • Read status for each message.
  • Unread message count in the channel.
  • Lastest message in the channel.

The GroupChannel has a special property, isDistinct. The distinct property enabled group channel is always reuesd for same channel members. If a new member gets invited or the member left from the channel, then the distinct property disabled automatically. If you don’t set distinct property on the channel, it always create new channel for the same members.

For more information, see Group Channel.

  • Last message of the channel.

    Declaration

    Swift

    open internal(set) var lastMessage: BaseMessage?
  • Represents the channel is super channel or not.

    Declaration

    Swift

    open internal(set) var isSuper: Bool
  • Represents the channel is broadcast channel or not.

    Since

    3.0.171

    Declaration

    Swift

    open internal(set) var isBroadcast: Bool
  • Represents the channel is exclusive channel or not.

    Since

    4.0.0

    Declaration

    Swift

    open internal(set) var isExclusive: Bool
  • Represents the channel is public channel or private one.

    Declaration

    Swift

    open internal(set) var isPublic: Bool
  • Represents that the channel has access code to enter.

    Since

    3.0.116

    Declaration

    Swift

    open internal(set) var isAccessCodeRequired: Bool
  • Represents the channel is distinct or not.

    Declaration

    Swift

    open internal(set) var isDistinct: Bool
  • Represents a boolean whether the public group channel is discoverable. It is only for a public group channel. The default value is true if the channel is a public group channel. If the channel is not a public group channel, the default value is false.

    Since

    3.0.136

    Declaration

    Swift

    open internal(set) var isDiscoverable: Bool
  • Since

    4.6.0

    Declaration

    Swift

    open internal(set) var isConversation: Bool
  • Since

    4.6.0

    Declaration

    Swift

    open internal(set) var isChatNotification: Bool
  • Unread message count of the channel.

    Declaration

    Swift

    open internal(set) var unreadMessageCount: UInt
  • The number of mentions that user does not read yet in the channel.

    Since

    3.0.103

    Declaration

    Swift

    open internal(set) var unreadMentionCount: UInt
  • Channel members

    Note

    Number of member for Super GroupChannel is limited to 10

    Declaration

    Swift

    open var members: [Member]
  • The number of members.

    Declaration

    Swift

    open internal(set) var memberCount: UInt = 0
  • The number of joined members.

    Declaration

    Swift

    open internal(set) var joinedMemberCount: UInt = 0
  • Timestamp when current user joined

    Since

    3.0.224

    Declaration

    Swift

    open internal(set) var joinedAt: Int64 = 0
  • Represents which push notification for the current user to receive in a group channel.

    Since

    3.0.128

    Declaration

    Swift

    open internal(set) var myPushTriggerOption: GroupChannelPushTriggerOption = .all
  • Represents this channel is hidden or not.

    Declaration

    Swift

    open internal(set) var isHidden: Bool = false
  • The hidden state of the channel.

    Since

    3.0.122

    Declaration

    Swift

    open internal(set) var hiddenState: GroupChannelHiddenState = .unhidden
  • Current member’s state in the channel.

    Declaration

    Swift

    open internal(set) var myMemberState: MemberState = .none
  • The role of current user in the channel.

    Declaration

    Swift

    open internal(set) var myRole: Role = .none
  • The muted state of the current user in the channel.

    Declaration

    Swift

    open internal(set) var myMutedState: MutedState = .unmuted
  • The preference lets to know counts in the channel. The default value is .all.

    Since

    3.0.102

    Declaration

    Swift

    open internal(set) var myCountPreference: CountPreference
  • The time stamp when the current user got a invitation from other user in the channel.

    Since

    3.0.107

    Declaration

    Swift

    open internal(set) var invitedAt: Int64 = 0
  • A last read information for the current user.

    Since

    3.0.138

    Declaration

    Swift

    open internal(set) var myLastRead: Int64 = 0
  • Message offset of a channel. User can only see messages after this offset.

    Since

    3.0.157

    Declaration

    Swift

    open var messageOffsetTimestamp: Int64
  • A value that sets the message survival time in seconds. In the channel that is created or updated with this option, the read messages are automatically deleted after a determined amount of time. The default value is -1 that represents the disappearing message is disabled.

    Note

    This feature is available in a 1-on-1 group channel.

    Since

    3.0.172

    Declaration

    Swift

    open internal(set) var messageSurvivalSeconds: Int = -1
  • Indicates whether this channel includes any AI bots.

    Since

    4.20.0

    Declaration

    Swift

    open internal(set) var hasAIBot: Bool = false
  • Indicates whether this channel includes any bots.

    Since

    4.20.0

    Declaration

    Swift

    open internal(set) var hasBot: Bool = false
  • Checks if the channel has a member that has userId.

    Declaration

    Swift

    open func hasMember(_ userId: String) -> Bool

    Parameters

    userId

    User ID.

    Return Value

    If true, the channel has the member.

  • Gets member in the channel.

    Declaration

    Swift

    open func getMember(_ userId: String) -> Member?

    Parameters

    userId

    User ID.

    Return Value

    Member object as a member. If there is a member who has the userId, Returns nil.

  • Gets a user who invites current user to this channel

    Declaration

    Swift

    open func getInviter() -> User?

    Return Value

    optional `User

  • Gets my delivery status in UTC timestamp

    Declaration

    Swift

    open func myDeliveryStatus() -> Int64
  • Compares two channel objects with the channel list order.

    Since

    3.0.227

    Declaration

    Swift

    open class func compare(
        channelA: GroupChannel,
        channelB: GroupChannel,
        order: GroupChannelListOrder
    ) -> Bool

    Parameters

    channelA

    First channel object.

    channelB

    Second channel obejct.

    order

    Order.

  • Default constructor.

    Declaration

    Swift

    public required init(from decoder: Decoder) throws

    Parameters

    decoder

    Decoder instance

  • Encodes this object.

    Declaration

    Swift

    public override func encode(to encoder: Encoder) throws

    Parameters

    encoder

    Encoder instance

  • Compares this object with given other object.

    Declaration

    Swift

    public override func isEqual(_ object: Any?) -> Bool

    Parameters

    object

    Any instance

    Return Value

    true if same otherwise false

CRUD

Update Channel

MultipleFileMessage

  • Sends a multipleFilesMessage with files (file or file URL) of params.

    For binary files in params.files, the data will be uploaded to Sendbird storage. For URL files in params.files, the URLs will be sent in the message.

    Declaration

    Swift

    public func sendMultipleFilesMessage(
        params: MultipleFilesMessageCreateParams,
        fileUploadHandler: FileUploadHandler?,
        completionHandler: @escaping MultipleFilesMessageHandler
    ) -> MultipleFilesMessage?

    Parameters

    params

    An intance of MultipleFilesMessageCreateParams that contains parameters needed to create a MultipleFilesMessage.

    fileUploadHandler

    A handler block to be executed after each file is uploaded. This block has no return value, and takes four arguments: first is requestId of a file, second is the index of a file, third is the UploadableFileInfo, and the fourth is the error made when there is a problem in uploading the file. This handler is called for both file-based UploadableFileInfo and file URL-based UploadableFileInfo.

    completionHandler

    A handler block to be executed after the message is sent. This block has no return value, and takes two arguments: one is a multipleFilesMessage that is sent, and the other is an error made when there is a problem in sending the message.

    Return Value

    A temporary multipleFilesMessage being sent to the Sendbird server. The sending status of the message is pending. The message has a request ID instead of a message ID.

ScheduledFileMessage

  • Creates a file message to be sent at the specified time.

    Note

    If a user leaves before sending scheduled messages, the scheduled messages will be removed.

    Since

    4.0.0

    Declaration

    Swift

    open func createScheduledFileMessage(
        params: ScheduledFileMessageCreateParams,
        completionHandler: FileMessageHandler?
    ) -> FileMessage?

    Parameters

    params

    The instance of ScheduledFileMessageCreateParams that can has parameters related with file message.

    completionHandler

    The handler block to be executed after the message is registered in the schedule. This block has no return value and takes two argument, one is a user message is registered in the schedule and other is an error made when there is something wrong to message.

  • Updates a scheduled file message.

    Note

    If a user leaves before sending scheduled messages, the scheduled messages will be removed.

    Since

    4.0.0

    Declaration

    Swift

    open func updateScheduledFileMessage(
        scheduledMessageId: Int64,
        params: ScheduledFileMessageUpdateParams,
        completionHandler: FileMessageHandler?
    )

    Parameters

    scheduledMessageId

    The scheduled message ID.

    params

    The instance of ScheduledFileMessageUpdateParams that can has parameters related with file message.

    completionHandler

    The handler block to be executed after the message is registered in the schedule. This block has no return value and takes two argument, one is a user message is registered in the schedule and other is an error made when there is something wrong to message.

ScheduledUserMessage

  • Creates a user message to be sent at the specified time.

    Note

    If a user leaves before sending scheduled messages, the scheduled messages will be removed.

    Since

    4.0.2

    Declaration

    Swift

    open func createScheduledUserMessage(
        params: ScheduledUserMessageCreateParams,
        completionHandler: UserMessageHandler?
    ) -> UserMessage?

    Parameters

    params

    The instance of ScheduledUserMessageCreateParams that can has parameters related with string message.

    completionHandler

    The handler block to be executed after the message is registered in the schedule. This block has no return value and takes two argument, one is a user message is registered in the schedule and other is an error made when there is something wrong to message.

  • Updates a user message to be sent at the specified time.

    Note

    If a user leaves before sending scheduled messages, the scheduled messages will be removed.

    Since

    4.0.0

    Declaration

    Swift

    open func updateScheduledUserMessage(
        scheduledMessageId: Int64,
        params: ScheduledUserMessageUpdateParams,
        completionHandler: UserMessageHandler?
    )

    Parameters

    scheduledMessageId

    The scheduled message ID.

    params

    The instance of ScheduledUserMessageUpdateParams that can has parameters related with string message.

    completionHandler

    The handler block to be executed after the message is registered in the schedule. This block has no return value and takes two argument, one is a user message is registered in the schedule and other is an error made when there is something wrong to message.

  • Sends the scheduled message now.

    Since

    4.0.0

    Declaration

    Swift

    open func sendScheduledMessageNow(
        scheduledMessageId: Int64,
        completionHandler: @escaping SBErrorHandler
    )

    Parameters

    scheduledMessageId

    The scheduled message ID.

    completionHandler

    The handler block to be executed after sending the scheduled message or when an error occurs.

  • Cancels the scheduled message.

    Since

    4.0.0

    Declaration

    Swift

    open func cancelScheduledMessage(
        scheduledMessageId: Int64,
        completionHandler: @escaping SBErrorHandler
    )

    Parameters

    scheduledMessageId

    The scheduled message ID.

    completionHandler

    The handler block to be executed after canceling the scheduled message or when an error occurs.

Copy

Resend

Delivery

  • Returns the delivery status as objects.

    [{USER_ID}: DeliveryStatus]
    

    USER_ID is the user ID as a key. Each USER_ID has a Dictionary which includes Member object and Int64. The “user” is a key of Member object and the “timestamp” is a key of Int64 object.

    Since

    4.12.2

    Declaration

    Swift

    public func getDeliveryStatus(with includeAllMembers: Bool) -> [String: DeliveryStatus]

    Parameters

    includeAllMembers

    If true, the return value includes the current user and the sender of the message.

    Return Value

    The delivery status. If there is no data, it will not be added to the dictionary.

Moderation

  • Freeze the channel. If channel is frozen, only operators can send messages to the channel.

    Since

    3.0.89

    Declaration

    Swift

    open func freeze(completionHandler: SBErrorHandler?)

    Parameters

    completionHandler

    The handler block to be executed after freeze.

  • Stop to freeze the channel. If It is not frozen channel, this will be ignored.

    Since

    3.0.89

    Declaration

    Swift

    open func unfreeze(completionHandler: SBErrorHandler?)

    Parameters

    completionHandler

    The handler block to be executed after stop to freeze.

Operator

  • Invites a single user to the group channel.

    Declaration

    Swift

    open func inviteUser(_ user: User, completionHandler: SBErrorHandler?)

    Parameters

    user

    The user to be invited.

    completionHandler

    The handler block to execute.

  • Invites a single user to the group channel.

    Declaration

    Swift

    open func inviteUserId(_ userId: String, completionHandler: SBErrorHandler?)

    Parameters

    userId

    The user ID to be invited.

    completionHandler

    The handler block to execute.

  • Invites multiple users to the group channel.

    Declaration

    Swift

    open func inviteUsers(_ users: [User], completionHandler: SBErrorHandler?)

    Parameters

    users

    The user array to be invited.

    completionHandler

    The handler block to execute.

  • Invites multiple users to the group channel.

    Declaration

    Swift

    open func inviteUserIds(_ userIds: [String], completionHandler: SBErrorHandler?)

    Parameters

    userIds

    The IDs of users array to be invited.

    completionHandler

    The handler block to execute.

  • Accpets the invitation.

    Declaration

    Swift

    open func acceptInvitation(completionHandler: SBErrorHandler?)

    Parameters

    completionHandler

    The handler block to execute.

  • Accpets the invitation from a public group channel that has access code.

    Since

    3.0.116

    Declaration

    Swift

    open func acceptInvitation(accessCode: String?, completionHandler: SBErrorHandler?)

    Parameters

    accessCode

    The string code is used to accept invitation from a public group channel.

    completionHandler

    The handler block to be executed after accepting. This block has no return value and takes an argument that is an error made when there is something wrong to accept.

  • Declines the invitation.

    Declaration

    Swift

    open func declineInvitation(completionHandler: SBErrorHandler?)

    Parameters

    completionHandler

    The handler block to execute.

  • Join a group channel

    Declaration

    Swift

    open func join(completionHandler: SBErrorHandler?)

    Parameters

    completionHandler

    The handler block to execute.

  • Join a public group channel that has access code.

    Since

    3.0.116

    Declaration

    Swift

    open func join(accessCode: String?, completionHandler: SBErrorHandler?)

    Parameters

    accessCode

    The string code is used to join a public group channel.

    completionHandler

    The handler block to be executed after joining. This block has no return value and takes an argument that is an error made when there is something wrong to join.

  • Leaves the group channel. The channel will be disappeared from the channel list. If join the channel, the invitation is required.

    Declaration

    Swift

    open func leave(completionHandler: SBErrorHandler?)

    Parameters

    completionHandler

    The handler block to execute.

  • Leaves the group channel. The channel will be disappeared from the channel list. If join the channel, the invitation is required.

    Since

    4.0.9

    Declaration

    Swift

    open func leave(shouldRemoveOperatorStatus: Bool, completionHandler: SBErrorHandler?)

    Parameters

    shouldRemoveOperatorStatus

    Set to true if you want the operator to remove the state when they leaves. Default is false

    completionHandler

    The handler block to execute.

  • Hides the group channel. The channel will be hid from the channel list, but it will be appeared again when the other user send a message in the channel.

    Declaration

    Swift

    open func hide(
        hidePreviousMessages: Bool,
        completionHandler: SBErrorHandler?
    )

    Parameters

    hidePreviousMessages

    The option to hide the previous message of this channel when the channel will be appeared again.

    completionHandler

    The handler block to execute.

  • Hides the group channel with the auto unhide option. The channel will be hid from the channel list. If the allowAutoUnhide is true, the channel will be appeared again when the other user send a message in the channel. However, if the allowAutoUnhide is false, the channel will be appeared by unhideChannel(completionHandler:) method.

    Since

    3.0.122

    Declaration

    Swift

    open func hide(
        hidePreviousMessages: Bool,
        allowAutoUnhide: Bool,
        completionHandler: SBErrorHandler?
    )

    Parameters

    hidePreviousMessages

    The option to hide the previous message of this channel when the channel will be appeared again.

    allowAutoUnhide

    The auto unhide option.

    completionHandler

    THe handle block to be executed.

  • Unhides the group channel.

    Since

    3.0.122

    Declaration

    Swift

    open func unhide(completionHandler: SBErrorHandler?)

    Parameters

    completionHandler

    THe handle block to be executed.

  • Sends mark as read. The other members in the channel will receive an event. The event will be received in channelDidUpdateReadStatus: of GroupChannelDelegate.

    Declaration

    Swift

    open func markAsRead(completionHandler: SBErrorHandler?)

    Parameters

    completionHandler

    completion handler

  • Notifies the current user took a screenshot in this channel. The server is going to send an admin message to notify this in the group channel.

    Since

    3.0.172

    Declaration

    Swift

    open func notifyScreenshotWasTaken(completionHandler: SBErrorHandler?)

    Parameters

    completionHandler

    The handler block to be executed.

Read

  • Returns how many members haven’t been read the given message yet.

    Since

    3.0.185

    Declaration

    Swift

    open func getUnreadMemberCount(_ message: BaseMessage) -> Int

    Parameters

    message

    The message.

    Return Value

    Number of unread member count. Zero if all members read the message.

  • Returns the members who read the given message.

    Since

    3.0.115

    Declaration

    Swift

    open func getReadMembers(
        message: BaseMessage,
        includeAllMembers: Bool
    ) -> [Member]

    Parameters

    message

    The message.

    includeAllMembers

    If true, the return value includes the current user and the sender of the message.

    Return Value

    Members who read the message.

  • Returns the members who didn’t read the given message.

    Since

    3.0.115

    Declaration

    Swift

    open func getUnreadMembers(
        message: BaseMessage,
        includeAllMembers: Bool
    ) -> [Member]

    Parameters

    message

    The message.

    includeAllMembers

    If true, the return value includes the current user and the sender of the message.

    Return Value

    Members who don’t read the message.

  • Returns how many members haven’t been delivery the given message yet.

    Since

    3.0.185

    Declaration

    Swift

    open func getUndeliveredMemberCount(_ message: BaseMessage) -> Int

    Parameters

    message

    The message.

    Return Value

    Number of undelivered member count. Zero if all members delivered the message.

  • Returns the read status.

    Since

    3.0.115

    [ USER_ID: [ “user”: User object, “last_seen_at”: Int64, ] ]

    USER_ID is the user ID as a key. Each USER_ID has a Dictionary which includes User object and Int64. The “user” is a key of User object and the “last_seen_at” is a key of Int64 object.

    Declaration

    Swift

    open func getReadStatus(includeAllMembers: Bool) -> [String: [String: Any]]

    Parameters

    includeAllMembers

    If true, the return value includes the current user and the sender of the message.

    Return Value

    The read status. If there’s no data, it will be an empty dictionary.

  • Returns the read status as objects.

    [{USER_ID}: ReadStatus]
    

    USER_ID is the user ID as a key. Each USER_ID has a Dictionary which includes User object and Int64. The “user” is a key of User object and the “last_seen_at” is a key of Int64 object.

    Since

    4.12.2

    Declaration

    Swift

    public func getReadStatus(with includeAllMembers: Bool) -> [String: ReadStatus]

    Parameters

    includeAllMembers

    If true, the return value includes the current user and the sender of the message.

    Return Value

    The read status. If there is no data, it will not be added to the dictionary.

Typing

  • Starts typing. The other members in the channel will receive an event.

    The event will be received in channelDidUpdateTypingStatus(_:) of GroupChannelDelegate.

    Declaration

    Swift

    open func startTyping()
  • Ends typing. The other members in the channel will receive an event.

    The event will be received in channelDidUpdateTypingStatus(_:) of GroupChannelDelegate.

    Declaration

    Swift

    open func endTyping()
  • Checks any members in the channel has been typing

    Declaration

    Swift

    open func isTyping() -> Bool

    Return Value

    true when other users are typing in this channel.

  • Returns the users who are typing now.

    Since

    3.0.202

    Declaration

    Swift

    open func getTypingUsers() -> [User]?

    Return Value

    The users who are typing now.

Configuration

  • Resets the history in this channel.

    Declaration

    Swift

    open func resetMyHistory(completionHandler: SBErrorHandler?)

    Parameters

    completionHandler

    The handler block to execute.

  • Changes a setting that decides which push notification for the current user to receive in the group channel.

    If a value of option is .default, a push trigger option in this group channel follows a push trigger option of the current user. It is related with SendbirdChat setPushTriggerOption(_:completionHandler:).

    Since

    3.0.128

    Declaration

    Swift

    open func setMyPushTriggerOption(
        _ option: GroupChannelPushTriggerOption,
        completionHandler: SBErrorHandler?
    )

    Parameters

    option

    options to choose which push notification for the current user to receive.

    completionHandler

    handler block to execute when setting a push trigger option of the current user is completed.

  • Requests a setting that decides which push notification for the current user to receive in the group channel.

    Since

    3.0.128

    Declaration

    Swift

    open func getMyPushTriggerOption(completionHandler: @escaping GroupChannelPushTriggerOptionHandler)

    Parameters

    completionHandler

    The handler block to execute when getting a push trigger option of the current user is completed.

  • Sets count preference of current user.

    Since

    3.0.102

    Declaration

    Swift

    open func setMyCountPreference(
        _ myCountPreference: CountPreference,
        completionHandler: SBErrorHandler?
    )

    Parameters

    myCountPreference

    Preference is type of CountPreference. The default value is .all.

Query