createChatThread method Null safety
Create Chat Thread.
Group members have permission. After chat thread is created, the following notices will appear:
- Members of the organization (group) to which chat thread belongs will receive the created notification event, and can listen to related events by setting {@link EMChatThreadManagerListener}. The event callback function is {@link EMChatThreadManagerListener#onChatThreadCreated(EMChatThreadEvent)}.
- Multiple devices will receive the notification event and you can set {@link com.hyphenate.EMMultiDeviceListener} to listen on the event. The event callback function is {@link com.hyphenate.EMMultiDeviceListener#onChatThreadEvent(EMMultiDevicesEvent, String, List)}, where the first parameter is the event, for example, {@link EMMultiDeviceListener#EMMultiDevicesEvent.CHAT_THREAD_CREATE} for the chat thread creation event.
Param name
Chat Thread name. No more than 64 characters in length.
Param messageId
Parent message ID, generally refers to group message ID.
Param parentId
Parent ID, generally refers to group ID.
Return EMChatThread object
Throws A description of the exception. See {@link EMError}.
Implementation
Future<EMChatThread> createChatThread({
required String name,
required String messageId,
required String parentId,
}) async {
Map req = {
"name": name,
"messageId": messageId,
"parentId": parentId,
};
Map result = await _channel.invokeMethod(
ChatMethodKeys.createChatThread,
req,
);
try {
EMError.hasErrorFromResult(result);
return EMChatThread.fromJson(result[ChatMethodKeys.createChatThread]);
} on EMError catch (e) {
throw e;
}
}