@@ -41,30 +41,53 @@ -(void)initWithDelegate{
4141 _notiArr = [NSMutableArray array ];
4242 if ([notifications count ])
4343 {
44+ // for (int i = 0; i < notifications.count - 1; i++) {
45+ // NIMSystemNotification *notices = [notifications objectAtIndex:i];
46+ // NIMSystemNotification *notices1 = [notifications objectAtIndex:i+1];
47+ // NSLog(@"555555555555555%@",notices.sourceID);
48+ // if ([notices.sourceID isEqualToString:notices1.sourceID]) {
49+ //
50+ // [[NIMSDK sharedSDK].systemNotificationManager markNotificationsAsRead:notices];
51+ // [[[NIMSDK sharedSDK] systemNotificationManager] deleteNotification:notices];
52+ // }
53+ // }
4454 for (int i = 0 ; i < notifications.count - 1 ; i++) {
45- NIMSystemNotification *notices = [notifications objectAtIndex: i];
46- NIMSystemNotification *notices1 = [notifications objectAtIndex: i+1 ];
47- if ([notices.sourceID isEqualToString: notices1.sourceID]) {
48- [[[NIMSDK sharedSDK ] systemNotificationManager ] deleteNotification: notices];
55+ for (int j = i+ 1 ; j < notifications.count ; j++) {
56+ NIMSystemNotification *notices = [notifications objectAtIndex: i];
57+ NIMSystemNotification *notices1 = [notifications objectAtIndex: j];
58+ if ([notices.sourceID isEqualToString: notices1.sourceID]) {
59+
60+ [[NIMSDK sharedSDK ].systemNotificationManager markNotificationsAsRead: notices];
61+ [[[NIMSDK sharedSDK ] systemNotificationManager ] deleteNotification: notices];
62+ }
63+
4964 }
50-
5165 }
66+
67+
5268 }
5369
70+ [self ReFrash ];
71+
72+ }
73+ -(void )ReFrash {
74+ id <NIMSystemNotificationManager> systemNotificationManager = [[NIMSDK sharedSDK ] systemNotificationManager ];
75+
5476 NSArray *Secnotifications = [systemNotificationManager fetchSystemNotifications: nil
5577 limit: MaxNotificationCount];
5678 if (Secnotifications.count ){
79+ [_notiArr removeAllObjects ];
80+ [_notifications removeAllObjects ];
5781 [_notifications addObjectsFromArray: Secnotifications];
5882 for (NIMSystemNotification *notices in _notifications) {
5983 NIMKitInfo *sourceMember = [[NIMKit sharedKit ] infoByUser: notices.sourceID option: nil ];
6084 [self updateSourceMember: sourceMember andNoti: notices];
6185 }
6286 [self refrash ];
6387 }
64-
65-
66-
6788}
89+
90+
6891- (void )stopSystemMsg {
6992 [[[NIMSDK sharedSDK ] systemNotificationManager ] removeDelegate: self ];
7093 [[[NIMSDK sharedSDK ] userManager ] removeDelegate: self ];
@@ -74,14 +97,16 @@ - (void)onSystemNotificationCountChanged:(NSInteger)unreadCount
7497{
7598 NIMModel *mode = [NIMModel initShareMD ];
7699 mode.unreadCount = unreadCount;
100+
101+
77102}
78103- (void )onReceiveSystemNotification : (NIMSystemNotification *)notification {
79104
80105 if (_notifications.count ) {
81106 for (NIMSystemNotification *notices in _notifications) {
82107
83108 if ([notices.sourceID isEqualToString: notification.sourceID]) {
84-
109+
85110 [[[NIMSDK sharedSDK ] systemNotificationManager ] deleteNotification: notices];
86111 [_notifications removeObject: notices];
87112
@@ -91,6 +116,7 @@ - (void)onReceiveSystemNotification:(NIMSystemNotification *)notification{
91116 [_notifications insertObject: notification atIndex: 0 ];
92117
93118 _shouldMarkAsRead = YES ;
119+ [_notiArr removeAllObjects ];
94120 for (NIMSystemNotification *notices in _notifications) {
95121 NIMKitInfo *sourceMember = [[NIMKit sharedKit ] infoByUser: notices.sourceID option: nil ];
96122 [self updateSourceMember: sourceMember andNoti: notices];
@@ -100,7 +126,7 @@ - (void)onReceiveSystemNotification:(NIMSystemNotification *)notification{
100126
101127
102128- (void )updateSourceMember : (NIMKitInfo *)sourceMember andNoti : (NIMSystemNotification *)noti {
103- [_notiArr removeAllObjects ];
129+
104130 NSMutableDictionary *dic = [NSMutableDictionary dictionary ];
105131 BOOL isVerify = false ;
106132 NIMSystemNotificationType type = noti.type ;
@@ -178,7 +204,9 @@ - (void)updateSourceMember:(NIMKitInfo *)sourceMember andNoti:(NIMSystemNotifica
178204 [dic setObject: [NSString stringWithFormat: @" %@ " ,url] forKey: @" avatar" ];
179205 [dic setObject: [NSString stringWithFormat: @" %ld " ,noti.handleStatus] forKey: @" status" ];
180206 [dic setObject: [NSString stringWithFormat: @" %f " ,noti.timestamp] forKey: @" time" ];
207+
181208 [_notiArr addObject: dic];
209+
182210}
183211// 加载更多
184212- (void )loadMore : (id )sender
@@ -193,17 +221,14 @@ - (void)loadMore:(id)sender
193221}
194222// 删除信息
195223-(void )deleteNotice : (NSString *)targetID timestamp : (NSString *)timestamp {
224+
196225 for (int i = 0 ; i < _notifications.count ; i++) {
197226 NIMSystemNotification *notices =_notifications[i];
198- if ([targetID isEqualToString: notices.targetID]) {
199- if ([timestamp isEqualToString: [NSString stringWithFormat: @" %.f " ,notices.timestamp]]) {
227+ if ([targetID isEqualToString: notices.sourceID]) {
200228 [[[NIMSDK sharedSDK ] systemNotificationManager ] deleteNotification: notices];
201- [_notiArr removeObjectAtIndex: i];
202-
203- }
204229 }
205230 }
206- [self refrash ];
231+ [self ReFrash ];
207232}
208233// 删除所有
209234-(void )deleAllNotic {
0 commit comments