Skip to content

Commit 1289444

Browse files
committed
Merge branch 'master' of github.com:reactnativecomponent/react-native-netease-im
2 parents b1166f7 + e4e8059 commit 1289444

File tree

3 files changed

+56
-40
lines changed

3 files changed

+56
-40
lines changed

ios/RNNeteaseIm/RNNeteaseIm/ContactViewController.m

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ -(void)initWithDelegate{
4040
_specialGroups = [[NSMutableOrderedSet alloc] init];
4141
_groupTtiles = [[NSMutableOrderedSet alloc] init];
4242
_groups = [[NSMutableOrderedSet alloc] init];
43-
[[[NIMSDK sharedSDK] systemNotificationManager] addDelegate:self];
43+
// [[[NIMSDK sharedSDK] systemNotificationManager] addDelegate:self];
4444
[[[NIMSDK sharedSDK] userManager] addDelegate:self];
4545

4646
// id<NIMSystemNotificationManager> systemNotificationManager = [[NIMSDK sharedSDK] systemNotificationManager];
@@ -353,17 +353,6 @@ - (void)onLogin:(NIMLoginStep)step
353353
}
354354
}
355355

356-
#pragma mark - NIMSDK Delegate
357-
- (void)onSystemNotificationCountChanged:(NSInteger)unreadCount//加好友未读条数
358-
{
359-
NIMModel *mode = [NIMModel initShareMD];
360-
mode.unreadCount = unreadCount;
361-
NSLog(@"-----------unreadCount:%zd",unreadCount);
362-
}
363-
364-
- (void)onReceiveSystemNotification:(NIMSystemNotification *)notification{
365-
NSLog(@"----notification:%@",notification);
366-
}
367356

368357
- (void)onUserInfoChanged:(NIMUser *)user
369358
{

ios/RNNeteaseIm/RNNeteaseIm/NIMModel.m

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ +(instancetype)initShareMD{
2626
//}
2727

2828
- (void)setRecentDict:(NSDictionary *)recentDict{
29-
if (_recentDict != recentDict) {
29+
if ((_recentDict != recentDict)&&(recentDict.count)) {
3030
_recentDict = recentDict;
3131
self.myBlock(1, recentDict);
3232
}
3333
}
3434

3535
-(void)setNetStatus:(NSString *)NetStatus{
36-
if (_NetStatus != NetStatus) {
36+
if ((_NetStatus != NetStatus)&&(NetStatus.length)) {
3737
_NetStatus = NetStatus;
3838
self.myBlock(0, NetStatus);
3939
}
4040
}
4141
-(void)setNIMKick:(NSString *)NIMKick{
42-
if (_NIMKick != NIMKick) {
42+
if ((_NIMKick != NIMKick)&&(NIMKick.length)) {
4343
_NIMKick = NIMKick;
4444
self.myBlock(2, NIMKick);
4545
}
@@ -51,36 +51,42 @@ -(void)setContactList:(NSMutableDictionary *)contactList{
5151
}
5252
}
5353
-(void)setNotiArr:(NSMutableArray *)notiArr{
54-
self.myBlock(5, notiArr);
54+
self.myBlock(5, notiArr);
5555
}
5656
-(void)setTeamArr:(NSMutableArray *)teamArr{
57-
if (teamArr.count) {
5857
self.myBlock(4, teamArr);
59-
}
6058
}
6159
//未读条数
6260
-(void)setUnreadCount:(NSInteger)unreadCount{
6361
self.myBlock(6, [NSString stringWithFormat:@"%ld",unreadCount]);
6462
}
6563
//
6664
-(void)setResorcesArr:(NSMutableArray *)ResorcesArr{
67-
self.myBlock(7, ResorcesArr);
65+
self.myBlock(7, ResorcesArr);
6866
}
6967
//开始发送
7068
-(void)setStartSend:(NSDictionary *)startSend{
71-
self.myBlock(8, startSend);
69+
if (startSend.count) {
70+
self.myBlock(8, startSend);
71+
}
7272
}
7373
//结束发送
7474
-(void)setEndSend:(NSDictionary *)endSend{
75-
self.myBlock(9, endSend);
75+
if (endSend.count) {
76+
self.myBlock(9, endSend);
77+
}
7678
}
7779
//发送进度(图片等附件)
7880
-(void)setProcessSend:(NSDictionary *)processSend{
79-
self.myBlock(10, processSend);
81+
if (processSend.count) {
82+
self.myBlock(10, processSend);
83+
}
8084
}
8185
//已读通知
8286
-(void)setReceipt:(NSString *)receipt{
83-
self.myBlock(11, receipt);
87+
if (receipt.length) {
88+
self.myBlock(11, receipt);
89+
}
8490
}
8591
//发送消息
8692
-(void)setSendState:(NSMutableArray *)sendState{
@@ -90,16 +96,22 @@ -(void)setSendState:(NSMutableArray *)sendState{
9096
}
9197
//黑名单列表
9298
-(void)setBankList:(NSMutableArray *)bankList{
93-
self.myBlock(13, bankList);
99+
if (bankList.count) {
100+
self.myBlock(13, bankList);
101+
}
94102
}
103+
95104
//录音进度
96105
-(void)setAudioDic:(NSDictionary *)audioDic{
97-
98-
self.myBlock(14, audioDic);
106+
if (audioDic.count) {
107+
self.myBlock(14, audioDic);
108+
}
99109
}
100110

101111
- (void)setDeleteMessDict:(NSDictionary *)deleteMessDict{
102-
self.myBlock(15, deleteMessDict);
112+
if (deleteMessDict.count) {
113+
self.myBlock(15, deleteMessDict);
114+
}
103115
}
104116

105117
@end

ios/RNNeteaseIm/RNNeteaseIm/NoticeViewController.m

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ @interface NoticeViewController ()<NIMUserManagerDelegate,NIMSystemNotificationM
1919

2020
@implementation NoticeViewController
2121

22+
- (void)dealloc{
23+
NSLog(@"NoticeViewController----dealloc");
24+
}
25+
2226
+(instancetype)initWithNoticeViewController{
2327
static NoticeViewController *notVC = nil;
2428
static dispatch_once_t onceToken;
@@ -34,7 +38,7 @@ -(void)initWithDelegate{
3438
_notifications = [NSMutableArray array];
3539
[self setAllread];
3640
id<NIMSystemNotificationManager> systemNotificationManager = [[NIMSDK sharedSDK] systemNotificationManager];
37-
[systemNotificationManager addDelegate:self];
41+
[systemNotificationManager addDelegate:nil];
3842

3943
NSArray *notifications = [systemNotificationManager fetchSystemNotifications:nil
4044
limit:MaxNotificationCount];
@@ -72,10 +76,12 @@ -(void)initWithDelegate{
7276
}
7377
-(void)ReFrash{
7478
id<NIMSystemNotificationManager> systemNotificationManager = [[NIMSDK sharedSDK] systemNotificationManager];
75-
79+
[systemNotificationManager addDelegate:self];
7680
NSArray *Secnotifications = [systemNotificationManager fetchSystemNotifications:nil
7781
limit:MaxNotificationCount];
78-
if(Secnotifications.count){
82+
83+
84+
7985
[_notiArr removeAllObjects];
8086
[_notifications removeAllObjects];
8187
[_notifications addObjectsFromArray:Secnotifications];
@@ -84,23 +90,33 @@ -(void)ReFrash{
8490
[self updateSourceMember:sourceMember andNoti:notices];
8591
}
8692
[self refrash];
87-
}
93+
8894
}
8995

9096

9197
- (void)stopSystemMsg{
92-
[[[NIMSDK sharedSDK] systemNotificationManager] removeDelegate:self];
98+
//[[[NIMSDK sharedSDK] systemNotificationManager] removeDelegate:self];
9399
[[[NIMSDK sharedSDK] userManager] removeDelegate:self];
94100
}
95101
#pragma mark - NIMSDK Delegate
96102
- (void)onSystemNotificationCountChanged:(NSInteger)unreadCount
97103
{
98104
NIMModel *mode = [NIMModel initShareMD];
99105
mode.unreadCount = unreadCount;
100-
106+
NSLog(@"2-----------unreadCount:%zd",unreadCount);
101107

102108
}
103109
- (void)onReceiveSystemNotification:(NIMSystemNotification *)notification{
110+
NSLog(@"2----notification:%@",notification);
111+
if (notification.type == NIMSystemNotificationTypeFriendAdd) {
112+
NIMUserAddAttachment *attach = notification.attachment;
113+
NSLog(@"2------attach.type:%zd",attach.operationType);
114+
if (attach.operationType == NIMUserOperationVerify) {//如果是通过添加好友请求,标为已读并删除
115+
[[NIMSDK sharedSDK].systemNotificationManager markNotificationsAsRead:notification];
116+
[[[NIMSDK sharedSDK] systemNotificationManager] deleteNotification:notification];
117+
}
118+
}
119+
104120

105121
if (_notifications.count) {
106122
for (NIMSystemNotification *notices in _notifications) {
@@ -221,7 +237,6 @@ - (void)loadMore:(id)sender
221237
}
222238
//删除信息
223239
-(void)deleteNotice:(NSString *)targetID timestamp:(NSString *)timestamp{
224-
225240
for (int i = 0; i < _notifications.count; i++) {
226241
NIMSystemNotification *notices =_notifications[i];
227242
if ([targetID isEqualToString:notices.sourceID]) {
@@ -424,12 +439,12 @@ -(void)onRefuse:(NSString *)targetID timestamp:(NSString *)timestamp sucess:(Suc
424439
completion:^(NSError *error) {
425440
if (!error) {
426441

427-
notices.handleStatus = NotificationHandleTypeNo;
428-
[_notifications replaceObjectAtIndex:i withObject:notices];
429-
for (NIMSystemNotification *notices in _notifications) {
430-
NIMKitInfo *sourceMember = [[NIMKit sharedKit] infoByUser:notices.sourceID option:nil];
431-
[self updateSourceMember:sourceMember andNoti:notices];
432-
}
442+
// notices.handleStatus = NotificationHandleTypeNo;
443+
// [_notifications replaceObjectAtIndex:i withObject:notices];
444+
// for (NIMSystemNotification *notices in _notifications) {
445+
// NIMKitInfo *sourceMember = [[NIMKit sharedKit] infoByUser:notices.sourceID option:nil];
446+
// [self updateSourceMember:sourceMember andNoti:notices];
447+
// }
433448
success(@"拒绝成功");
434449

435450
}

0 commit comments

Comments
 (0)