Create 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.

  • 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 also 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.

TPChannel? channel = await TalkPlusAPI.createChannel(
    targetIds, 
    channelId, 
    reuseChannel, 
    maxMemberCount, 
    hideMessagesBeforeJoin, 
    channelType, 
    channelName, 
    invitationCode, 
    category, 
    subcategory, 
    imageUrl, 
    metaData,
    errorCallback: (errorCode, errorMessage){}
);

2. Delete Channel

Only the channel owner can delete channel.

await TalkPlusAPI.deleteChannel(
    channelId, 
    errorCallback: (errorCode, errorMessage){}
);

Last updated