createCustomMessage

Introduction

Create a custom message.

For details, you can referring to this document.

Parameter details

Parameter name Parameter type Required Platform Description
data String yes All The custom data of the message.
desc String no All The custom description of the message.
extension String no All The custom extension of the message.

Returned template

V2TimValueCallback<V2TimMsgCreateInfoResult>

{
    code: int,
    desc: String,
    data: {
        id: String,
        messageInfo: V2TimMessage,
    }
}

Return value details

name type description
code int Request result: Error codes. 0 means success.
desc String The description of the failure.
data V2TimMsgCreateInfoResult The created custom message on local.

Code example

    V2TimValueCallback<V2TimMsgCreateInfoResult> createCustomMessageRes =
        await TencentImSDKPlugin.v2TIMManager
            .getMessageManager()
            .createCustomMessage(
              data: 'The data of the message.',
              desc: 'The description of the message.',
              extension: 'The extension of the message.',
            );
    if (createCustomMessageRes.code == 0) {
      String? id = createCustomMessageRes.data?.id;
      V2TimValueCallback<V2TimMessage> sendMessageRes = await TencentImSDKPlugin
          .v2TIMManager
          .getMessageManager()
          .sendMessage(id: id!, receiver: "userID", groupID: "groupID");
      if (sendMessageRes.code == 0) {
        sendMessageRes.data?.customElem?.data; 
        sendMessageRes.data?.customElem?.desc; 
        sendMessageRes.data?.customElem?.extension; 
      }
    }

results matching ""

    No results matching ""