Chat / iOS
Chat iOS v4
Chat iOS
Chat
iOS
Home
/
Chat
/
iOS
/
Channel
This is the new Docs for Chat SDK v4 for iOS. To see the previous Docs, click here.

Accept or decline an invitation

A user who is invited to a group channel can accept or decline the invitation. If a user accepts an invitation, they join the channel as a new member and can start chatting with other members. If the user declines the invitation, the invitation is no longer valid.

Users can join up to 2,000 group channels. When the number of group channels a user can join reaches the maximum number, new invitations are automatically declined.

// Accept an invitation.
channel.acceptInvitation { error in
    guard error == nil else {
        // Handle error.
        return 
    }
}

// Decline an invitation.
channel.declineInvitation { error in
    guard error == nil else {
        // Handle error.
        return 
    }
}

You can set the channel invitation preference for your Sendbird application. The preference determines whether a user can automatically accept a group channel invitation or manually accept invitations. If the value of setChannelInvitationPreference(autoAccept:completionHandler:) is set to true, invitations will be automatically accepted. If the value is false, users can either accept or decline invitations. By default, the value is set to true.

// The default value of true means that
// a user will automatically join a group channel
// even if the user hasn't accepted the invitation.
var autoAccept = false
SendbirdChat.setChannelInvitationPreference(autoAccept: autoAccept) { error in
    guard error == nil else {
        // Handle error.
        return 
    }
}

If the client app is in the foreground, the members of the group channel are notified of whether the newly invited user has accepted or declined the invitation. To do so, implement the channel(_:didReceiveInvitation:inviter:) and channel(_:didDeclineInvitation:inviter:) methods in the channel delegate. For more information, see the event delegate page.