chat.createTextMessage(options);
options
parameter is of the Object
type. The attribute it contains is as follows:Parameters | Type | Description |
to | String | The userID or groupID of the message recipient |
conversationType | String | The conversation type, with values TencentCloudChat.TYPES.CONV_C2C (end-to-end conversation) or TencentCloudChat.TYPES.CONV_GROUP (group conversation) |
priority | String | Message priority. If the message frequency limit is exceeded within the group, the backend will prioritize delivering high-priority messages. Supported enumeration values: TencentCloudChat.TYPES.MSG_PRIORITY_HIGH TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default) TencentCloudChat.TYPES.MSG_PRIORITY_LOW TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST |
payload | Object | Message content container |
cloudCustomData | String | Custom message data, which is saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled |
receiverList | Array | undefined | List of group members for targeted message reception (not supported for community and live broadcast groups) |
isSupportExtension | Boolean | Whether message extension is supported, true for supported, false for not supported (requires you to purchase the advanced package) |
payload
is as follows:Parameters | Type | Description |
text | String | Message text content |
// Send text messages, same for Web and Mini Program// 1. Create a message instance, the instance returned by the interface can be displayedlet message = chat.createTextMessage({to: 'user1',conversationType: TencentCloudChat.TYPES.CONV_C2C,// Message priority for group chat. If the message frequency limit is exceeded in a group, the backend will prioritize high-priority messages// priority: TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL,payload: {text: 'Hello world!'},// If you need read receipts for your messages, you need to purchase the flagship package and set needReadReceipt to true when creating the messageneedReadReceipt: true// Custom message data, saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled// cloudCustomData: 'your cloud custom data'});// 2. Send a messagelet promise = chat.sendMessage(message);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});
// Sending a Targeted Group Message// Note: Targeted group messages are excluded from the unread count of a conversation. `receiverList` supports up to 50 recipients.let message = chat.createTextMessage({to: 'group1',conversationType: TencentCloudChat.TYPES.CONV_GROUP,payload: {text: 'Hello world!'},// To send a targeted group message, you must purchase the Enterprise Edition Package and specify the message receivers through receiverList when creating the messagereceiverList: ['user0', 'user1']});// Send a message.let promise = chat.sendMessage(message);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});
chat.createTextAtMessage(options);
options
parameter is of the Object
type. The attribute it contains is as follows:Parameters | Type | Description |
to | String | The userID or groupID of the message recipient |
conversationType | String | The conversation type, with values TencentCloudChat.TYPES.CONV_C2C (end-to-end conversation) or TencentCloudChat.TYPES.CONV_GROUP (group conversation) |
priority | String | Message priority. If the message frequency limit is exceeded within the group, the backend will prioritize delivering high-priority messages. Supported enumeration values: TencentCloudChat.TYPES.MSG_PRIORITY_HIGH TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default) TencentCloudChat.TYPES.MSG_PRIORITY_LOW TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST |
payload | Object | Message content container |
cloudCustomData | String | Custom message data, which is saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled |
payload
is as follows:Parameters | Type | Description |
text | String | Message text content |
atUserList | Array | The list of users to @. If you need to @ALL, pass in TencentCloudChat.TYPES.MSG_AT_ALL. For example, if you want to @ notify both denny and lucy in this text message, and also @ everyone, pass ['denny', 'lucy', TencentCloudChat.TYPES.MSG_AT_ALL] to atUserList. |
// Send text messages, same for Web and Mini Program// 1. Create a message instance, the instance returned by the interface can be displayedlet message = chat.createTextAtMessage({to: 'group1',conversationType: TencentCloudChat.TYPES.CONV_GROUP,// Message priority for group chat// priority: TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL,payload: {text: '@denny @lucy @everyone Dinner tonight, please reply 1 if received',// 'denny' and 'lucy' are userIDs, not nicknamesatUserList: ['denny', 'lucy', TencentCloudChat.TYPES.MSG_AT_ALL]},// Custom message data, saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled// cloudCustomData: 'your cloud custom data'});// 2. Send a messagelet promise = chat.sendMessage(message);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});
npm install react-native-image-picker --save
chat.createImageMessage(options);
options
parameter is of the Object
type. The attribute it contains is described in the following table:Parameters | Type | Description |
to | String | Message recipient |
conversationType | String | The conversation type, with values TencentCloudChat.TYPES.CONV_C2C or TencentCloudChat.TYPES.CONV_GROUP |
priority | String | Message priority. If the message frequency limit is exceeded within the group, the backend will prioritize delivering high-priority messages. Supported enumeration values: TencentCloudChat.TYPES.MSG_PRIORITY_HIGH TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default) TencentCloudChat.TYPES.MSG_PRIORITY_LOW TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST |
payload | Object | Message content container |
onProgress | function | Callback function to get upload progress |
cloudCustomData | String | Custom message data, which is saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled |
payload
is as follows:Parameters | Type | Description |
file | HTMLInputElement | Object | File | DOM node for selecting images (Web) or File object (Web) The success callback parameter of the wx.chooseImage interface. The SDK will read the data and upload the image. |
import {launchImageLibrary} from 'react-native-image-picker';// 1. Select an ImagelaunchImageLibrary({mediaType: 'photo',selectionLimit: 1,}).then((result) => {const file = result.assets[0];// 2. Create a message instance. The instance returned by the interface can be displayed on the screenlet message = chat.createImageMessage({to: 'user1',conversationType: TencentCloudChat.TYPES.CONV_C2C,payload: { file: file },// React Native does not support upload progress callback// onProgress: function(event) { console.log('file uploading:', event) }});// 3. Send Imagelet promise = chat.sendMessage(message);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});});
import {launchCamera} from 'react-native-image-picker';// 1. Take PhotolaunchCamera({mediaType: 'photo',cameraType: 'back',}).then((result) => {const file = result.assets[0];// 2. Create a message instance. The instance returned by the interface can be displayed on the screenlet message = chat.createImageMessage({to: 'user1',conversationType: TencentCloudChat.TYPES.CONV_C2C,payload: { file: file },// React Native does not support upload progress callback// onProgress: function(event) { console.log('file uploading:', event) }});// 3. Send Imagelet promise = chat.sendMessage(message);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});});
npm install react-native-audio-recorder-player --save
chat.createAudioMessage(options);
options
parameter is of the Object
type. The attribute it contains is as follows:Parameters | Type | Description |
to | String | Message recipient |
conversationType | String | The conversation type, with values TencentCloudChat.TYPES.CONV_GROUP or TencentCloudChat.TYPES.CONV_GROUP |
priority | String | Message priority. If the message frequency limit is exceeded within the group, the backend will prioritize delivering high-priority messages. Supported enumeration values: TencentCloudChat.TYPES.MSG_PRIORITY_HIGH TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default) TencentCloudChat.TYPES.MSG_PRIORITY_LOW TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST |
payload | Object | Message content container |
cloudCustomData | String | Custom message data, which is saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled |
payload
is as follows:Parameters | Type | Description |
file | Object | Information of the file obtained after recording |
import AudioRecorderPlayer, {AVEncodingOption} from 'react-native-audio-recorder-player';// Record the recording duration, unit: mslet duration = 0;// Record recording file pathlet uri = '';// 1. Start recordingconst onStartRecord = async () => {await audioRecorderPlayer.startRecorder('test.aac',{VFormatIDKeyIOS: AVEncodingOption.aac,});audioRecorderPlayer.addRecordBackListener((e: any) => {duration = e.currentPosition;});};// 2. Stop recordingconst onStopRecord = async () => {uri = await audioRecorderPlayer.stopRecorder();audioRecorderPlayer.removeRecordBackListener();};// 3. Send voiceconst file = {uri: uri,duration: duration,};let message = chat.createAudioMessage({to: 'user1',conversationType: 'C2C',payload: {file: file,},// React Native does not support upload progress callback// onProgress: function(event) { console.log('file uploading:', event) }});let promise = chat.sendMessage(message);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});
npm install react-native-image-picker --save
chat.createVideoMessage(options);
options
parameter is of the Object
type. The attribute it contains is as follows:Parameters | Type | Description |
to | String | Message recipient |
conversationType | String | The conversation type, with values TencentCloudChat.TYPES.CONV_GROUP or TencentCloudChat.TYPES.CONV_GROUP |
priority | String | Message priority. If the message frequency limit is exceeded within the group, the backend will prioritize delivering high-priority messages. Supported enumeration values: TencentCloudChat.TYPES.MSG_PRIORITY_HIGH TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default) TencentCloudChat.TYPES.MSG_PRIORITY_LOW TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST |
payload | Object | Message content container |
cloudCustomData | String | Custom message data, which is saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled |
Parameters | Type | Description |
file | HTMLInputElement | File | Object | Data fields of custom messages |
import {launchImageLibrary} from 'react-native-image-picker';// 1. Select a VideolaunchImageLibrary({mediaType: 'video',selectionLimit: 1,}).then((result) => {const file = result.assets[0];// 2. Create a message instance. The instance returned by the interface can be displayed on the screenlet message = chat.createVideoMessage({to: 'user1',conversationType: TencentCloudChat.TYPES.CONV_C2C,payload: { file: file },// React Native does not support upload progress callback// onProgress: function(event) { console.log('file uploading:', event) }});// 3. Send Videolet promise = chat.sendMessage(message);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});});
import {launchCamera} from 'react-native-image-picker';// 1. Record VideolaunchCamera({mediaType: 'video',cameraType: 'back',}).then((result) => {const file = result.assets[0];// 2. Create a message instance. The instance returned by the interface can be displayed on the screenlet message = chat.createVideoMessage({to: 'user1',conversationType: TencentCloudChat.TYPES.CONV_C2C,payload: { file: file },// React Native does not support upload progress callback// onProgress: function(event) { console.log('file uploading:', event) }});// 3. Send Videolet promise = chat.sendMessage(message);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});});
chat.createCustomMessage(options);
options
parameter is of the Object
type. The attribute it contains is as follows:Parameters | Type | Description |
to | String | The userID or groupID of the message recipient |
conversationType | String | The conversation type, with values TencentCloudChat.TYPES.CONV_GROUP or TencentCloudChat.TYPES.CONV_GROUP |
priority | String | Message priority. If the message frequency limit is exceeded within the group, the backend will prioritize delivering high-priority messages. Supported enumeration values: TencentCloudChat.TYPES.MSG_PRIORITY_HIGH TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default) TencentCloudChat.TYPES.MSG_PRIORITY_LOW TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST |
payload | Object | Message content container |
cloudCustomData | String | Custom message data, which is saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled |
payload
is as follows:Parameters | Type | Description |
data | String | Data fields of custom messages |
description | String | // Field that describes the custom message |
extension | String | // Field that extends the custom message |
// Example: Implementing dice rolling using custom messages// 1. Define a random functionfunction random(min, max) {return Math.floor(Math.random() * (max - min + 1) + min);}// 2. Create a message instance. The instance returned by the interface can be displayed on the screenlet message = chat.createCustomMessage({to: 'user1',conversationType: TencentCloudChat.TYPES.CONV_C2C,// Message priority for group chat// priority: TencentCloudChat.TYPES.MSG_PRIORITY_HIGH,payload: {data: 'dice', // Identifies the message as a dice type messagedescription: String(random(1,6)), // Get dice pointsextension: ''}});// 3. Send a messagelet promise = chat.sendMessage(message);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});
chat.createFaceMessage(options);
options
parameter is of the Object
type. The attribute it contains is as follows:Parameters | Type | Description |
to | String | The userID or groupID of the message recipient |
conversationType | String | The conversation type, with values TencentCloudChat.TYPES.CONV_C2C or TencentCloudChat.TYPES.CONV_GROUP |
priority | String | Message priority. If the message frequency limit is exceeded within the group, the backend will prioritize delivering high-priority messages. Supported enumeration values: TencentCloudChat.TYPES.MSG_PRIORITY_HIGH TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default) TencentCloudChat.TYPES.MSG_PRIORITY_LOW TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST |
payload | Object | Message content container |
cloudCustomData | String | Custom message data, which is saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled |
payload
is as follows:Parameters | Type | Description |
index | Number | Emoji index, user-defined |
data | String | Extra data |
// Send emoji messages, same for Web and Mini Program.// 1. Create a message instance, the instance returned by the interface can be displayedlet message = chat.createFaceMessage({to: 'user1',conversationType: TencentCloudChat.TYPES.CONV_C2C,// Message priority for group chat// priority: TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL,payload: {index: 1, // Number Emoji index, user-defineddata: 'tt00' // String Extra data},// Custom message data, saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled// cloudCustomData: 'your cloud custom data'});// 2. Send a messagelet promise = chat.sendMessage(message);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});
npm install react-native-document-picker --save
chat.createFileMessage(options);
options
parameter is of the Object
type. The attribute it contains is as follows:Parameters | Type | Description |
to | String | The userID or groupID of the message recipient |
conversationType | String | The conversation type, with values TencentCloudChat.TYPES.CONV_C2C or TencentCloudChat.TYPES.CONV_GROUP |
priority | String | Message priority. If the message frequency limit is exceeded within the group, the backend will prioritize delivering high-priority messages. Supported enumeration values: TencentCloudChat.TYPES.MSG_PRIORITY_HIGH TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default) TencentCloudChat.TYPES.MSG_PRIORITY_LOW TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST |
payload | Object | Message content container |
onProgress | function | Callback function to get upload progress |
cloudCustomData | String | Custom message data, which is saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled |
payload
is as follows:Parameters | Type | Description |
file | HTMLInputElement | File | Object | The DOM node for selecting files (Web) or File object (Web) or Object (success callback parameter of the uni.chooseFile API). The SDK will read the data and upload the file. |
import DocumentPicker from 'react-native-document-picker';// 1. Select FileDocumentPicker.pick({type: [DocumentPicker.types.allFiles],}).then((result) => {const file = result[0];// 2. Create a message instance. The instance returned by the interface can be displayed on the screenlet message = chat.createFileMessage({to: 'user1',conversationType: TencentCloudChat.TYPES.CONV_C2C,payload: { file: file },// React Native does not support upload progress callback// onProgress: function(event) { console.log('file uploading:', event) }});// 3. Send Filelet promise = chat.sendMessage(message);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});});
chat.createLocationMessage(options);
options
parameter is of the Object
type. The attribute it contains is as follows:Parameters | Type | Description |
to | String | The userID or groupID of the message recipient |
conversationType | String | The conversation type, with values TencentCloudChat.TYPES.CONV_C2C or TencentCloudChat.TYPES.CONV_GROUP |
priority | String | Message priority. If the message frequency limit is exceeded within the group, the backend will prioritize delivering high-priority messages. Supported enumeration values: TencentCloudChat.TYPES.MSG_PRIORITY_HIGH TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default) TencentCloudChat.TYPES.MSG_PRIORITY_LOW TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST |
payload | Object | Message content container |
cloudCustomData | String | Custom message data, which is saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled |
payload
is as follows:Parameters | Type | Description |
description | String | Location description information |
longitude | Number | Longitude |
latitude | Number | Latitude |
// Send location messages, same for Web and Mini Program// 1. Create a message instance, the instance returned by the interface can be displayedlet message = chat.createLocationMessage({to: 'user1',conversationType: TencentCloudChat.TYPES.CONV_C2C,// Message priority for group chat// priority: TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL,payload: {description: 'Tencent Building, 10000 Shennan Avenue, Shenzhen',longitude: 113.941079, // Longitudelatitude: 22.546103 // Latitude}});// 2. Send a messagelet promise = chat.sendMessage(message);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});
chat.createMergerMessage(options);
options
parameter is of the Object
type. The attribute it contains is as follows:Parameters | Type | Description |
to | String | The userID or groupID of the message recipient |
conversationType | String | The conversation type, with values TencentCloudChat.TYPES.CONV_C2C or TencentCloudChat.TYPES.CONV_GROUP |
priority | String | Message priority. If the message frequency limit is exceeded within the group, the backend will prioritize delivering high-priority messages. Supported enumeration values: TencentCloudChat.TYPES.MSG_PRIORITY_HIGH TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL (default) TencentCloudChat.TYPES.MSG_PRIORITY_LOW TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST |
payload | Object | Message content container |
cloudCustomData | String | Custom message data, which is saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled |
payload
is as follows:Parameters | Type | Description |
messageList | Array | Merged message list |
title | String | Title of merged messages, for example, "Chat History of the Talent Center in the Greater Bay Area" |
abstractList | String | abstractList: Different message types can have different abstract information. For example, a text message can be set as: sender: text, an image message can be set as: sender: [Image], and a file message can be set as: sender: [File]. |
compatibleText | String | compatible text: If the lower version SDK does not support merged messages, a text message will be received by default. The content of the text message is ${compatibleText}, required. |
// 1. Forward group chat messages to c2c session// message1 message2 message3 are group chat messageslet mergerMessage = chat.createMergerMessage({to: 'user1',conversationType: TencentCloudChat.TYPES.CONV_C2C,payload: {messageList: [message1, message2, message3],title: 'Chat records of the Greater Bay Area Front-end Talent Center',abstractList: ['allen: 666', 'iris: [Image]', 'linda: [File]'],compatibleText: 'Upgrade your Chat SDK to v2.10.1 or later to view this message.'},// Custom message data, saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled// cloudCustomData: 'your cloud custom data'});// 2. Send a messagelet promise = chat.sendMessage(mergerMessage);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});
chat.downloadMergerMessage(message);
Parameters | Type | Description |
message | Message | Message instance |
Promise
// The presence of downloadKey indicates that the received merged message is stored in the cloud and needs to be downloaded first.if (message.type === TencentCloudChat.TYPES.MSG_MERGER && message.payload.downloadKey !== '') {let promise = chat.downloadMergerMessage(message);promise.then(function(imResponse) {// After the download is successful, the SDK will update information such as message.payload.messageList.console.log(imResponse.data);}).catch(function(imError) {// Download failedconsole.warn('downloadMergerMessage error:', imError);});}
chat.createForwardMessage(message);
Parameters | Type | Description |
message | Message | Message instance |
let forwardMessage = chat.createForwardMessage({to: 'user1',conversationType: TencentCloudChat.TYPES.CONV_C2C,// Message priority for group chat// priority:TencentCloudChat.
TYPES.MSG_PRIORITY_NORMAL,payload: message, // Message instance for the received or sent message// Custom message data, saved in the cloud, will be sent to the peer end, and can still be pulled after the application is uninstalled and reinstalled// cloudCustomData: 'your cloud custom data'});// 2. Send a messagelet promise = chat.sendMessage(forwardMessage);promise.then(function(imResponse) {// Sending succeeded.console.log(imResponse);}).catch(function(imError) {// Sending fails.console.warn('sendMessage error:', imError);});
TencentCloudChat.EVENT.SDK_READY
- triggered when the SDK is in the ready state.TencentCloudChat.EVENT.SDK_NOT_READY
- triggered when the SDK is in the not ready state.chat.sendMessage(options);
options
parameter is of the Object
type. The attribute it contains is as follows:Parameters | Type | Description |
message | Message | Message instance |
options | Object | Message sending options (message content container), optional |
options
is as follows:Parameters | Type | Description |
onlineUserOnly | Boolean | Indicator of whether the message is sent only to online users, default value is false; if set to true, the message will neither be stored in roaming nor counted as unread, and will not be pushed offline to the recipient. Suitable for scenarios such as sending broadcast notifications or other unimportant prompt messages. This option is not supported when sending messages in AVChatRoom. |
offlinePushInfo | Object | |
messageControlInfo | Object | Message control configuration |
offlinePushInfo
is as follows:Parameters | Type | Description |
disablePush | Boolean | true to disable offline push; false to enable offline push (default) |
disableVoipPush | Boolean | true to disable voip push (default); false to enable voip push (enabling voip push requires offline push to be enabled) |
title | String | Offline push title, this field is shared by iOS and Android |
description | String | Offline push content. This field will override the offline push display text of the message instance. If a custom message is sent, this description field will override message.payload.description. If neither description nor message.payload.description is filled, the recipient will not receive the offline push of this custom message. |
extension | String | Offline push pass-through content |
androidInfo | Object | Android push configuration |
apnsInfo | Object | iOS push configuration |
androidInfo
is as follows:Parameters | Type | Description |
sound | String | Android offline push sound settings. Only supported by Huawei, Xiaomi, and Google. For Xiaomi phones with Android 8.0 and above, you must set androidInfo.XiaoMiChannelID. Please refer to: Custom ringtone for Xiaomi. Google Phone FCM Push on Android 8.0 and above systems requires setting androidInfo.FCMChannelID for sound notifications. Custom ringtone requires setting the sound file path. For example: androidInfo.sound = "shake.xxx" Corresponding to the uniapp "nativeResources/android/res/raw/shake.xxx" audio file. Corresponding to the native application's "/res/raw/shake.xxx" audio file. |
XiaoMiChannelID | String | Notification category (Channel) adaptation field for Xiaomi phones with MIUI 10 and above. |
OPPOChannelID | String | NotificationChannel adaptation fields for OPPO phones with Android 8.0 and above. |
FCMChannelID | String | Notification channel fields for Google phones with Android 8.0 and above. |
VIVOClassification | Number | VIVO phone push message classification, 0: operational message, 1: system message, default is 1. |
VIVOCategory | String | Used to identify message type on VIVO phones. |
HuaWeiCategory | String | Used to identify message type on Huawei phones. |
HuaWeiImage | String | Huawei push notification bar notification image URL, supported from v3.4.1. The protocol used must be HTTPS, example value: https://example.com/image.png Image files must be smaller than 512 KB, with recommended dimensions of 40dp x 40dp and a corner radius of 8dp. Images exceeding the recommended specifications may be compressed or not fully displayed. Recommended formats are JPG/JPEG/PNG. |
HonorImage | String | Honor push notification bar notification image URL, supported from v3.4.1. The protocol used must be HTTPS, example value: https://example.com/image.png Icon files must be smaller than 100 KB, with recommended dimensions of 160px x 160px and a corner radius of 32px. Icons exceeding the recommended specifications may be compressed or not fully displayed. |
GoogleImage | String | Google push notification bar notification image URL, supported from v3.4.1. The protocol used must be HTTPS, example value: https://example.com/image.png Icon files must be smaller than 1 MB. Icons exceeding the recommended specifications may be compressed or not fully displayed. |
apnsInfo
is as follows:Parameters | Type | Description |
sound | String | iOS offline push sound settings. When apnsInfo.sound = TencentCloudChat.TYPES.IOS_OFFLINE_PUSH_NO_SOUND, it means no sound will be played upon receiving. When apnsInfo.sound = TencentCloudChat.TYPES.IOS_OFFLINE_PUSH_DEFAULT_SOUND, it means the system sound will be played upon receiving. Custom ringtone requires setting the sound file path. For example: apnsInfo.sound = "shake.xxx" Corresponding to the uniapp "nativeResources/ios/Resources/shake.xxx" file, uniapp must be a release package. Corresponding to the native Xcode project's "shake.xxx" audio file. |
ignoreIOSBadge | Boolean | Offline push ignores badge count (effective only for iOS), default is false. When set to true, this message will not increase the app icon's unread count on the iOS receiving end. |
disableVoipPush | Boolean | true to disable voip push (default); false to enable voip push (enabling voip push requires offline push to be enabled) |
image | String | Identifies the APNs notification bar notification image URL. When the client receives this field, it can display the image in the popup by downloading the image resource. Supported from v3.4.1. The protocol used must be HTTPS, example value: https://example.com/image.png Supports JPEG, GIF, PNG, size not exceeding 10 MB. The mutable-content attribute needs to be enabled in the IM console to support iOS 10 Service Extension features. The key value of the resource is "image". |
messageControlInfo
is as follows:Parameters | Type | Description |
excludedFromUnreadCount | Boolean | true: The message does not update the conversation unreadCount (message stored in roaming), default value is false. |
excludedFromLastMessage | Boolean | true: The message does not update the conversation lastMessage (message stored in roaming), default value is false. |
excludedFromContentModeration | Boolean | Whether the message bypasses content moderation (cloud moderation). The excludedFromContentModeration setting is only effective after enabling the [cloud moderation] feature. Set to true to bypass content moderation, set to false to pass content moderation. |
Promise
// If the recipient is offline, the message will be stored for roaming and an offline push will be triggered (when the recipient's app is in the background or the process is killed).// The title and content of the offline push use default values.// For details on offline push, please refer to https://www.tencentcloud.com/document/product/1047/33525chat.sendMessage(message);
chat.sendMessage(message, {onlineUserOnly: true // If the recipient is offline, the message will not be stored for roaming and will not trigger an offline push});
chat.sendMessage(message, {offlinePushInfo: {disablePush: true // If the recipient is offline, the message will be stored for roaming but will not trigger an offline push}});
chat.sendMessage(message, {// If the recipient is offline, the message will be stored for roaming and an offline push will be triggered (when the recipient's app is in the background or the process is killed).// The access side can customize the title and content of offline pushofflinePushInfo: {title: '', // Offline push titledescription: '', // Offline push contentandroidOPPOChannelID: '' // Offline push setting for OPPO phones with system 8.0 and above channel ID}});
chat.sendMessage(message, {messageControlInfo: {excludedFromUnreadCount: true, // The message does not update the conversation unreadCount (message stored in roaming)excludedFromLastMessage: true // The message does not update the conversation lastMessage (message stored in roaming)}});
// The message bypasses content moderationchat.sendMessage(message, {messageControlInfo: {excludedFromContentModeration: true,}});
// Supports VoIP pushchat.sendMessage(message, {offlinePushInfo: {disablePush: false,disableVoipPush: false}});
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.RECORD_AUDIO" />
<key>NSCameraUsageDescription</key><string>We need access to your camera to take photos</string><key>NSPhotoLibraryUsageDescription</key><string>We need access to your album to select photos</string><key>NSMicrophoneUsageDescription</key><string>We need access to your microphone to record audio</string>
Features | Restriction Item | Explanation |
One-to-one chat/Group chat | Content length | The maximum length of a single one-to-one or group chat message is 12K. |
| Sending frequency | One-to-one chat messages: No limit for client-sent messages; REST API sent messages have frequency limits, refer to the respective interface documentation. Group chat messages: Limited to 40 messages per second per group (applies to all group types and all platform interfaces). Frequency limits in different groups do not affect each other. |
| Receiving frequency | No limit for both one-to-one and group chats. |
| Individual File Size | When sending file messages, the SDK supports a maximum individual file size of 100 MB. |
Was this page helpful?