setMessageListener
Feature Introduction
Description
Set a message event listener to provide asynchronous callback notifications for message-related events, so that the UI can perceive and handle them promptly.
Note
- Call immediately after
initSDK
. - Can only be called once.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future setAdvancedMsgListener(OnAdvancedMsgListener listener)
Return Value
Parameter Name | Data Type | Description |
---|---|---|
listener | OnAdvancedMsgListener | Required |
Code Example
OpenIM.iMManager.messageManager.setAdvancedMsgListener(OnAdvancedMsgListener(
onMsgDeleted: (Message msg){},
onNewRecvMessageRevoked: (RevokedInfo info){},
onRecvC2CReadReceipt: (List<ReadReceiptInfo> list){},
onRecvGroupReadReceipt: (List<ReadReceiptInfo> list){},
onRecvMessageExtensionsAdded: (String msgID, List<KeyValue> list){},
onRecvMessageExtensionsChanged: (String msgID, List<KeyValue> list){},
onRecvMessageExtensionsDeleted: (String msgID, List<String> list){},
onRecvOfflineNewMessages: (List<Message> list){},
onRecvNewMessage: (Message msg){},
));
Function Prototype
- (void)addAdvancedMsgListener:(id<OIMAdvancedMsgListener>)listener NS_SWIFT_NAME(addAdvancedMsgListener(listener:));
Return Value
Parameter Name | Data Type | Description |
---|---|---|
listener | id < OIMAdvancedMsgListener > | Required |
Code Example
[OIMManager.callbacker addAdvancedMsgListener:self];
Function Prototype
public void setAdvancedMsgListener(OnAdvanceMsgListener listener)
Input Parameter
Parameter Name | Data Type | Description |
---|---|---|
listener | OnAdvancedMsgListener | Required |
Code Example
OpenIMClient.getInstance().messageManager.setAdvancedMsgListener(new OnAdvanceMsgListener() {
public void onRecvNewMessage(Message msg) {
}
public void onRecvC2CReadReceipt(List<ReadReceiptInfo> list) {
}
public void onRecvGroupMessageReadReceipt(List<ReadReceiptInfo> list) {
}
public void onRecvMessageRevoked(String msgId) {
}
public void onRecvMessageRevokedV2(RevokedInfo info) {
}
public void onRecvMessageExtensionsChanged(String msgID, List<KeyValue> list) {
}
public void onRecvMessageExtensionsDeleted(String msgID, List<String> list) {
}
public void onRecvMessageExtensionsAdded(String msgID, List<KeyValue> list) {
}
public void onMsgDeleted(Message message) {
}
public void onRecvOfflineNewMessages(List<Message> list) {
}
});
Note
After successful login, it is automatically set. Clients can directly use the listener. For message event details, see.
Note
After successful initialization, it is automatically set. The callback will be transmitted to the client through globalEvent
. For message event details, see.
Attention
After successful initialization, it's set automatically. You can directly use the listener on the client side. Details on message events can be found here
注意
登录成功后自动设置,可以直接在客户端使用监听,消息事件详情参见
Function Prototype
public static void SetAdvancedMsgListener(IAdvancedMsgListener l)
Input Parameter
Parameter Name | Parameter Type | Description | |
---|---|---|---|
l | OnAdvancedMsgListener | Yes |
Code Example
IMSDK.SetAdvancedMsgListener(listener);