createImageMessage

Introduction

Create an image message.

The maximum size limit for the image is 28MB.

For Android and iOS, you are supposed to provide the local absolute path of the image.

For Web, you should provide the input DOM element, with image selected.

Demo code shows here.

Please do not provide a URL on network to path.

Parameter details

Parameter name Parameter type Required Platform Description
imagePath String yes All The local absolute path of the image, used for Android and iOS.
inputElement dynamic no All The DOM element of the input, used for Web.
fileName String no All The file name.

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 image message created.

Code example

    V2TimValueCallback<V2TimMsgCreateInfoResult> createImageMessageRes =
        await TencentImSDKPlugin.v2TIMManager
            .getMessageManager()
            .createImageMessage(
              imagePath: "The absolute path of the image.", 
            );
    if (createImageMessageRes.code == 0) {
      String id = createImageMessageRes.data.id;
      V2TimValueCallback<V2TimMessage> sendMessageRes = await TencentImSDKPlugin
          .v2TIMManager
          .getMessageManager()
          .sendMessage(id: id, receiver: "userID", groupID: "groupID");
      if (sendMessageRes.code == 0) {
      }
    }

results matching ""

    No results matching ""