custom_elem_data
stores the polling title and options. And store the user ID of the voter and selected option(s) in the key
and value
of the message extension, respectively. With the selected options of users, we can calculate the polling percentage in real time.custom_elem_data
stores the title of the group notice, and then store the user ID and the corresponding info in the key
and value
of the message extension, respectively.custom_elem_data
stores the title and options of the survey, and then store the user ID and the corresponding info in the key
and value
of the message extension, respectively.MsgSetMessageExtensions
API (details) to set the message extension. If an extension already exists, modify its value
info. Otherwise, add new ones.setMessageExtensions
API are detailed as follows:Attribute | Definition | Description |
message | Message object | Three message conditions to meet: The message is sent successfully. The message is not a message of a community/audio-video group. |
extensions | Extensions | Modify the `value` info of an existing extension, or add new extensions. |
key
and value
of an extension can contain up to 100 B and 1 KB, respectively. You can set up to 20 extensions each time and 300 extensions for a message.key
of the same extension simultaneously, only the first user can operate successfully, and other users will receive the error code 23001 and the latest extension info in the setting response packet, who can set it again if necessary.userID
can be set as the key
of the extension in polling, group notices and survey.// Setting message extensionvar list = new List<MessageExtension>{new MessageExtension{message_extension_key = "key",message_extension_value = "value"}};TIMResult res = TencentIMSDK.MsgSetMessageExtensions(message, list, (int code, string desc, List<MessageExtensionResult> results, string user_data)=>{// Async result of the message extension setting});
// Get message extensionsTIMResult res = TencentIMSDK.MsgGetMessageExtensions(message, (int code, string desc, List<MessageExtension> list, string user_data)=>{// Async result of the message extension getting});
MsgDeleteMessageExtensions
API (details) to delete message extensions. If the value of the keys
field is set to null
, all message extensions will be cleared.// Delete message extensionsvar list = new List<MessageExtension>{new MessageExtension{message_extension_key = "key",message_extension_value = "value"}};TIMResult res = TencentIMSDK.MsgDeleteMessageExtensions(message, list, (int code, string desc, List<MessageExtensionResult> results, string user_data)=>{// Async result of the message extension deletion});
SetMsgExtensionsChangedCallback
API, when a message extension is added or updated, you will receive a MsgExtensionsChangedCallback
(details) callback.
If you have added an event listener for advanced messages via the SetMsgExtensionsDeletedCallback
API, when a message extension is added or updated, you will receive a MsgExtensionsDeletedCallback
(details) callback.// Add an event listener for advanced messagesTencentIMSDK.SetMsgExtensionsChangedCallback((string message_id, List<MessageExtension> message_extension_array, string user_data) => {// `message_extension_array` is the list of the modified message extension objects});TencentIMSDK.SetMsgExtensionsDeletedCallback((string message_id, List<MessageExtension> message_extension_array, string user_data) => {// `message_extension_array` is the list of the deleted message extension objects});
Was this page helpful?