融云-补偿消息删除

2021-09-07  本文已影响0人  月沉眠love
1、清除历史消息。在清除历史消息成功的回调中,删除会话,并且给该会话发一条不存储不计数的命令消息,作用是表示该会话历史消息已经被清除。
截屏2021-09-07 下午2.34.34.png

//代码示例:

// 清除历史消息

[[RCIMClient sharedRCIMClient] clearHistoryMessages:**self**.conversationType targetId:**self**.targetId recordTime:0 clearRemote:**YES** success:^{
    NSLog(@"++++ 清除历史消息成功");
    NSLog(@"++++ 删除会话");
    [[RCIMClient sharedRCIMClient] removeConversation:**self**.conversationType targetId:**self**.targetId];

    // 发送删除消息和会话命令,name和data您自己定义

    RCCommandMessage *message = [[RCCommandMessage alloc] init];

    message.name = @"删除";

    message.data = [NSString stringWithFormat:@"%ld", **self**.conversationType];

    **if** (**self**.conversationType == ConversationType_SYSTEM) {

        NSLog(@"++++ 系统会话,删除命令发单聊消息");

        [[RCIM sharedRCIM] sendMessage:ConversationType_PRIVATE targetId:**self**.targetId content:message pushContent:**nil** pushData:**nil** success:^(**long** messageId) {

            NSLog(@"++++ 删除命令发送成功");

        } error:^(RCErrorCode nErrorCode, **long** messageId) {

            NSLog(@"++++ 删除命令发送失败 %ld", nErrorCode);

        }];

    } **else** {

        [**self** sendMessage:message pushContent:**nil**];

    }

} error:^(RCErrorCode status) {
    NSLog(@"++++ 清除历史消息失败 %ld", status);
}];
2、(可选)该会话有新消息产生。
3、卸载重装应用
4、触发“消息补偿”机制,除了收到之前删除过的消息,还会收到删除的命令消息和删除后的新消息。
5、在消息接收监听中实现下面逻辑。
截屏2021-09-07 下午2.35.44.png 截屏2021-09-07 下午2.36.56.png

//代码示例:

2021年5月27日 16:05版本

上一篇 下一篇

猜你喜欢

热点阅读