createChannel method

Future<AgoraRtmChannel?> createChannel(
  1. String channelId
)

Creates an AgoraRtmChannel.

channelId is the unique channel name of the Agora RTM session. The string length must not exceed 64 bytes with the following character scope:

  • The 26 lowercase English letters: a to z
  • The 26 uppercase English letters: A to Z
  • The 10 numbers: 0 to 9
  • Space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "]", "[", "^", "_", " {", "}", "|", "~", "," channelId cannot be empty or set as nil.

Implementation

Future<AgoraRtmChannel?> createChannel(String channelId) async {
  final res = await _callNative("createChannel", {'channelId': channelId});
  if (res['errorCode'] != 0)
    throw AgoraRtmClientException(
        "createChannel failed errorCode:${res['errorCode']}",
        res['errorCode']);
  AgoraRtmChannel channel = AgoraRtmChannel(_clientIndex, channelId);
  _channels[channelId] = channel;
  return _channels[channelId];
}