Create / Delete Channel

1. Create Channel

You need to create a channel in order to chat.

  • targetId can be retrieved by calling getUserId method provided by TPUser object

  • You can enter up to 5 key-value pairs in data field. The maximum size of key is 128 characters and the maximum size of value is 1024 characters. Both key and value must be strings.

  • Supported channel types are follows: private, public, invitationOnly, broadcast, super_broadcast, super_private and super_public.

  • type field is required.

  • invitationCode field is required for invitationOnly channel type.

  • If hideMessagesBeforeJoin parameter is set to true, members who join the channel will not be able to see messages from before the time they join.

Type

Value

Can Join Channel

FCM Support

PRIVATE

private

X

O

PUBLIC

public

O

O

INVITATION ONLY

invitationOnly

O (need Invitation Code)

O

BROADCAST

broadcast

O

O

SUPER_BROADCAST

super_broadcast

O

X

SUPER_PRIVATE

super_private

O

X

SUPER_PUBLIC

super_public

O

X

  • For private channel, setting reuseChannel to true allows you to reuse existing channel if channel ID and member IDs match those of existing channel and members. This feature is useful when implementing 1:1 chat.

  • Anyone can join a public channel, except for banned users.

  • For invitationOnly channel, invitationCode field is required.

  • For broadcast and super_broadcast channel:

    • When the channel owner sends a message, the message is sent to all channel members.

    • When a channel member other than the channel owner sends a message, the message is sent only to the channel owner.

  • For super_broadcast, super_private and super_public channel:

    • You can set the maximum number of members above 100.

    • Set the maximum member limit to -1 allows unlimited members.

    • super channel returns empty members , bannedUsers and mutedUsers fields.

    • unreadCount, invitationCode, lastReadAt fields are not supported.

    • FCM push notifications are not sent since there can be too many users and notifications.

[[TalkPlus sharedInstance] createChannelWithUserIds:userIds channelId:channelId reuseChannel:reuseChannel maxMemberCount:maxMemberCount hideMessagesBeforeJoin:hideMessagesBeforeJoin channelType:channelType channelName:channelName invitationCode:invitationCode imageUrl:imageUrl metaData:metaData success:^(TPChannel *tpChannel) {
    // SUCCESS
} failure:^(int errorCode, NSError *error) {
    // FAILURE
}];
[[TalkPlus sharedInstance] createChannelWithUserIds:userIds 
    channelId:channelId 
    reuseChannel:reuseChannel 
    maxMemberCount:maxMemberCount 
    hideMessagesBeforeJoin:hideMessagesBeforeJoin 
    channelType:channelType 
    channelName:channelName 
    invitationCode:invitationCode 
    category:category 
    subcategory:subcategory 
    imageUrl:imageUrl 
    metaData:metaData 
    success:^(TPChannel *tpChannel) {
    // SUCCESS
} failure:^(int errorCode, NSError *error) {
    // FAILURE
}];
  1. Delete Channel

Only the channel owner can delete channel.

[TalkPlus sharedInstance] deleteChannel:channelID success:^
    // SUCCESS
} failure:^(int errorCode, NSError *error) {
    // FAILURE
}];

Last updated