Skip to content

Commit 1df3e8d

Browse files
guangyaoguangyao
authored andcommitted
Fix 撤回消息等相关问题
1 parent 5b59596 commit 1df3e8d

File tree

3 files changed

+40
-17
lines changed

3 files changed

+40
-17
lines changed

ios/RNNeteaseIm/RNNeteaseIm/ConversationViewController.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,10 @@ typedef void(^Errors)(id erro);
6767
- (void)onTouchVoiceSucc:(Success)succ Err:(Errors)err;
6868
//更新录音消息为已播放
6969
- (void)updateAudioMessagePlayStatus:(NSString *)messageID;
70+
71+
//获得撤回内容
72+
- (NSString *)tipOnMessageRevoked:(id)message;
73+
//更具提示生成撤回消息
74+
- (NIMMessage *)msgWithTip:(NSString *)tip;
75+
7076
@end

ios/RNNeteaseIm/RNNeteaseIm/ConversationViewController.m

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -615,23 +615,22 @@ - (void)onRecvMessageReceipt:(NIMMessageReceipt *)receipt
615615
mode.receipt = @"1";
616616
}
617617

618-
619-
- (void)onRecvRevokeMessageNotification:(NIMRevokeMessageNotification *)notification
620-
{
621-
NSString * tip = [self tipOnMessageRevoked:notification];
622-
NIMMessage *tipMessage = [self msgWithTip:tip];
623-
NIMMessageSetting *setting = [[NIMMessageSetting alloc] init];
624-
setting.shouldBeCounted = NO;
625-
tipMessage.setting = setting;
626-
tipMessage.timestamp = notification.timestamp;
627-
NIMMessage *deleMess = notification.message;
628-
NSDictionary *deleteDict = @{@"_id":deleMess.messageId};
629-
[NIMModel initShareMD].deleteMessDict = deleteDict;
630-
// saveMessage 方法执行成功后会触发 onRecvMessages: 回调,但是这个回调上来的 NIMMessage 时间为服务器时间,和界面上的时间有一定出入,所以要提前先在界面上插入一个和被删消息的界面时间相符的 Tip, 当触发 onRecvMessages: 回调时,组件判断这条消息已经被插入过了,就会忽略掉。
631-
[[NIMSDK sharedSDK].conversationManager saveMessage:tipMessage
632-
forSession:notification.session
633-
completion:nil];
634-
}
618+
//写到RNNotificationCenter去了
619+
//- (void)onRecvRevokeMessageNotification:(NIMRevokeMessageNotification *)notification
620+
//{
621+
// NSString * tip = [self tipOnMessageRevoked:notification];
622+
// NIMMessage *tipMessage = [self msgWithTip:tip];
623+
// tipMessage.timestamp = notification.timestamp;
624+
// NIMMessage *deleMess = notification.message;
625+
// NSDictionary *deleteDict = @{@"msgId":deleMess.messageId};
626+
//
627+
// // saveMessage 方法执行成功后会触发 onRecvMessages: 回调,但是这个回调上来的 NIMMessage 时间为服务器时间,和界面上的时间有一定出入,所以要提前先在界面上插入一个和被删消息的界面时间相符的 Tip, 当触发 onRecvMessages: 回调时,组件判断这条消息已经被插入过了,就会忽略掉。
628+
// [[NIMSDK sharedSDK].conversationManager saveMessage:tipMessage
629+
// forSession:notification.session
630+
// completion:^(NSError * _Nullable error) {
631+
// [NIMModel initShareMD].deleteMessDict = deleteDict;
632+
// }];
633+
//}
635634

636635
#pragma mark - NIMMediaManagerDelegate
637636
- (void)recordAudio:(NSString *)filePath didBeganWithError:(NSError *)error {

ios/RNNeteaseIm/RNNeteaseIm/RNNotificationCenter.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "NSDictionary+NTESJson.h"
1212
#import "NIMMessageMaker.h"
1313
#import "NIMModel.h"
14+
#import "ConversationViewController.h"
1415
@interface RNNotificationCenter () <NIMSystemNotificationManagerDelegate,NIMChatManagerDelegate>
1516
@property (nonatomic,strong) AVAudioPlayer *player; //播放提示音
1617
@end
@@ -96,6 +97,23 @@ - (void)checkTranferMessage:(NSArray *)messages{
9697

9798
}
9899

100+
#pragma mark -- NIMChatManagerDelegate
101+
- (void)onRecvRevokeMessageNotification:(NIMRevokeMessageNotification *)notification
102+
{
103+
NSString * tip = [[ConversationViewController initWithConversationViewController] tipOnMessageRevoked:notification];
104+
NIMMessage *tipMessage = [[ConversationViewController initWithConversationViewController] msgWithTip:tip];
105+
tipMessage.timestamp = notification.timestamp;
106+
NIMMessage *deleMess = notification.message;
107+
if (deleMess) {
108+
NSDictionary *deleteDict = @{@"msgId":deleMess.messageId};
109+
[NIMModel initShareMD].deleteMessDict = deleteDict;
110+
}
111+
112+
// saveMessage 方法执行成功后会触发 onRecvMessages: 回调,但是这个回调上来的 NIMMessage 时间为服务器时间,和界面上的时间有一定出入,所以要提前先在界面上插入一个和被删消息的界面时间相符的 Tip, 当触发 onRecvMessages: 回调时,组件判断这条消息已经被插入过了,就会忽略掉。
113+
[[NIMSDK sharedSDK].conversationManager saveMessage:tipMessage
114+
forSession:notification.session
115+
completion:nil];
116+
}
99117
#pragma mark - NIMSystemNotificationManagerDelegate
100118
- (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification{//接收自定义通知
101119
// NSString *content = notification.content;

0 commit comments

Comments
 (0)