recallMessage static method
撤回消息
当接收方离线并允许远程推送时,会收到远程推送。
远程推送中包含两部分内容,一是pushContent
,用于显示;二是pushData
,用于携带不显示的数据。
SDK内置的消息类型,如果您将pushContent
和pushData
置为空或者为null,会使用默认的推送格式进行远程推送。
自定义类型的消息,需要您自己设置pushContent和pushData来定义推送内容,否则将不会进行远程推送。
Implementation
static Future<RecallNotificationMessage?> recallMessage(Message? message, String? pushContent) async {
if (message == null) {
developer.log("send message fail: conversationType or targetId or content is null", name: "RongIMClient");
return null;
}
if (pushContent == null) {
pushContent = "";
}
Map msgMap = MessageFactory.instance!.message2Map(message);
Map map = {"message": msgMap, "pushContent": pushContent};
Map? resultMap = await _channel.invokeMethod(RCMethodKey.RecallMessage, map);
if (resultMap == null) {
return null;
}
String? messageString = resultMap["recallNotificationMessage"];
if (messageString == null || messageString.isEmpty) {
developer.log("send message fail: conversationType or targetId or content is null", name: "RongIMClient");
return null;
}
RecallNotificationMessage? msg = MessageFactory.instance!.string2MessageContent(messageString, RecallNotificationMessage.objectName) as RecallNotificationMessage?;
return msg;
}