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.
Please do not provide a URL on network to path.
Parameter details
Parameter name | Parameter type | Required | Description |
---|---|---|---|
imagePath | string | yes | The local absolute path of the image |
Returned template
V2TimValueCallback<V2TimMsgCreateInfoResult>
{
code: number,
desc: string,
data: {
id: string,
messageInfo: V2TimMessage,
}
}
Return value details
name | type | description |
---|---|---|
code | number | Request result: Error codes. 0 means success. |
desc | string | The description of the error. It will be empty if success. |
data | V2TimMsgCreateInfoResult | The image message created. |
Code example
import { TencentImSDKPlugin } from 'react-native-tim-js';
const createImageMessageRes = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.createImageMessage(
'本地图片绝对路径'
);
if (createImageMessageRes.code === 0) {
const id = createImageMessageRes.data?.id;
const sendMessageRes = await TencentImSDKPlugin.v2TIMManager
.getMessageManager()
.sendMessage({ id: id!, receiver: 'userID', groupID: 'groupID' });
if (sendMessageRes.code === 0) {
}
}