Skip to content

Commit 0149401

Browse files
committed
Merge branch 'master' of github.com:reactnativecomponent/react-native-netease-im
# Conflicts: # index.js
2 parents feb620a + 2ccd37b commit 0149401

File tree

6 files changed

+58
-47
lines changed

6 files changed

+58
-47
lines changed

android/src/main/java/com/netease/im/common/ImageLoaderKit.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ private void init(ImageLoaderConfiguration config) {
7878

7979
public void clear() {
8080
ImageLoader.getInstance().clearMemoryCache();
81+
cacheLoad.clear();
8182
}
8283

8384
private ImageLoaderConfiguration getDefaultConfig() throws IOException {

ios/RNNeteaseIm/RNNeteaseIm/ContactViewController.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ -(void)initWithDelegate{
4343
[[[NIMSDK sharedSDK] systemNotificationManager] addDelegate:self];
4444
[[[NIMSDK sharedSDK] userManager] addDelegate:self];
4545

46-
id<NIMSystemNotificationManager> systemNotificationManager = [[NIMSDK sharedSDK] systemNotificationManager];
47-
[systemNotificationManager addDelegate:self];
48-
notifications = [systemNotificationManager fetchSystemNotifications:nil limit:20];
46+
// id<NIMSystemNotificationManager> systemNotificationManager = [[NIMSDK sharedSDK] systemNotificationManager];
47+
// [systemNotificationManager addDelegate:self];
48+
// notifications = [systemNotificationManager fetchSystemNotifications:nil limit:20];
4949
}
5050

5151
- (void)disealloc{
@@ -348,12 +348,16 @@ - (void)onLogin:(NIMLoginStep)step
348348
}
349349

350350
#pragma mark - NIMSDK Delegate
351-
- (void)onSystemNotificationCountChanged:(NSInteger)unreadCount
351+
- (void)onSystemNotificationCountChanged:(NSInteger)unreadCount//加好友未读条数
352352
{
353353
NIMModel *mode = [NIMModel initShareMD];
354354
mode.unreadCount = unreadCount;
355+
NSLog(@"-----------unreadCount:%zd",unreadCount);
355356
}
356357

358+
- (void)onReceiveSystemNotification:(NIMSystemNotification *)notification{
359+
NSLog(@"----notification:%@",notification);
360+
}
357361

358362
- (void)onUserInfoChanged:(NIMUser *)user
359363
{

ios/RNNeteaseIm/RNNeteaseIm/ConversationViewController.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ -(void)localSession:(NSInteger)index cerrentmessageId:(NSString *)currentMessage
6464
_index = index;
6565
[[NIMSDK sharedSDK].conversationManager markAllMessagesReadInSession:_session];
6666
if (currentMessageID.length != 0) {
67+
6768
NSArray *currentMessage = [[[NIMSDK sharedSDK] conversationManager] messagesInSession:_session messageIds:@[currentMessageID] ];
6869
NIMMessage *currentM = currentMessage[0];
6970
NSArray *messageArr = [[[NIMSDK sharedSDK] conversationManager]messagesInSession:_session message:currentM limit: index];
7071
if (messageArr.count != 0) {
7172
succe([self setTimeArr:messageArr]);
7273
}else{
74+
7375
err(@"暂无更多");
7476
}
7577

ios/RNNeteaseIm/RNNeteaseIm/NoticeViewController.m

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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{

ios/RNNeteaseIm/RNNeteaseIm/RNNeteaseIm.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ - (dispatch_queue_t)methodQueue
2929
[self setSendState];
3030
[[NIMViewController initWithController] addDelegate];
3131
[[RNNotificationCenter sharedCenter] start];
32+
[[NoticeViewController initWithNoticeViewController]initWithDelegate];
3233
resolve(account);
3334
}else{
3435
reject(@"-1",error, nil);

ios/RNNeteaseIm/RNNeteaseIm/RNNotificationCenter.m

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -83,35 +83,13 @@ - (void)checkMessageAt:(NSArray *)messages
8383
}
8484

8585
#pragma mark - NIMSystemNotificationManagerDelegate
86-
- (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification{
86+
- (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification{//接收自定义通知
8787

8888
NSString *content = notification.content;
89-
90-
NSData *data = [content dataUsingEncoding:NSUTF8StringEncoding];
91-
if (data)
92-
{
93-
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data
94-
options:0
95-
error:nil];
96-
NSLog(@"收到------消息%@",[dict jsonString:NTESCustomContent]);
97-
if ([dict isKindOfClass:[NSDictionary class]])
98-
{
99-
if ([dict jsonInteger:NTESNotifyID] == NTESCustom)
100-
{
101-
NSLog(@"收到消息%@",notification);
102-
// //SDK并不会存储自定义的系统通知,需要上层结合业务逻辑考虑是否做存储。这里给出一个存储的例子。
103-
// NTESCustomNotificationObject *object = [[NTESCustomNotificationObject alloc] initWithNotification:notification];
104-
// //这里只负责存储可离线的自定义通知,推荐上层应用也这么处理,需要持久化的通知都走可离线通知
105-
// if (!notification.sendToOnlineUsersOnly) {
106-
// [[NTESCustomNotificationDB sharedInstance] saveNotification:object];
107-
// }
108-
// if (notification.setting.shouldBeCounted) {
109-
// [[NSNotificationCenter defaultCenter] postNotificationName:NTESCustomNotificationCountChanged object:nil];
110-
// }
111-
NSString *content = [dict jsonString:NTESCustomContent];
112-
NSLog(@"收到消息%@",content);
113-
// [[NTESMainTabController instance].selectedViewController.view makeToast:content duration:2.0 position:CSToastPositionCenter];
114-
}
89+
NSDictionary *notiDict = notification.apnsPayload;
90+
if (notiDict){
91+
if ([[notiDict objectForKey:@"type"] integerValue]==1) {//加好友
92+
11593
}
11694
}
11795
}

0 commit comments

Comments
 (0)