Skip to content

Commit 8f12ee3

Browse files
guangyaoguangyao
authored andcommitted
add 监听资金变动
1 parent 159231b commit 8f12ee3

File tree

5 files changed

+41
-17
lines changed

5 files changed

+41
-17
lines changed

ios/RNNeteaseIm/RNNeteaseIm/NIMModel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ typedef void(^onSuccess)(NSInteger index,id param);
2929
@property(nonatomic,strong)NSMutableArray *bankList;
3030
@property(nonatomic,strong)NSDictionary *audioDic;
3131
@property (strong, nonatomic) NSDictionary *deleteMessDict;//撤销时删除的消息ID
32+
@property (strong, nonatomic) NSDictionary *accountNoticeDict;//接收到资金变动的消息
3233
- (void)insertMessages:(NSArray *)messages;
3334
@end

ios/RNNeteaseIm/RNNeteaseIm/NIMModel.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,11 @@ - (void)setDeleteMessDict:(NSDictionary *)deleteMessDict{
146146
}
147147
}
148148

149+
150+
- (void)setAccountNoticeDict:(NSDictionary *)accountNoticeDict{
151+
if (self.myBlock) {
152+
self.myBlock(16, accountNoticeDict);
153+
}
154+
}
155+
149156
@end

ios/RNNeteaseIm/RNNeteaseIm/NIMViewController.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,17 @@ -(void)getRecentContactListsuccess:(SUCCESS)suc andError:(ERROR)err{
157157
for (NIMRecentSession *recent in NIMlistArr) {
158158
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
159159
[dic setObject:[NSString stringWithFormat:@"%@",recent.session.sessionId] forKey:@"contactId"];
160-
[dic setObject:[NSString stringWithFormat:@"%ld", recent.session.sessionType] forKey:@"sessionType"];
160+
[dic setObject:[NSString stringWithFormat:@"%zd", recent.session.sessionType] forKey:@"sessionType"];
161161
//未读
162-
[dic setObject:[NSString stringWithFormat:@"%ld", recent.unreadCount] forKey:@"unreadCount"];
162+
[dic setObject:[NSString stringWithFormat:@"%zd", recent.unreadCount] forKey:@"unreadCount"];
163163
//群组名称或者聊天对象名称
164164
[dic setObject:[NSString stringWithFormat:@"%@", [self nameForRecentSession:recent] ] forKey:@"name"];
165165
//账号
166166
[dic setObject:[NSString stringWithFormat:@"%@", recent.lastMessage.from] forKey:@"account"];
167167
//消息类型
168-
[dic setObject:[NSString stringWithFormat:@"%ld", recent.lastMessage.messageType] forKey:@"msgType"];
168+
[dic setObject:[NSString stringWithFormat:@"%zd", recent.lastMessage.messageType] forKey:@"msgType"];
169169
//消息状态
170-
[dic setObject:[NSString stringWithFormat:@"%ld", recent.lastMessage.deliveryState] forKey:@"msgStatus"];
170+
[dic setObject:[NSString stringWithFormat:@"%zd", recent.lastMessage.deliveryState] forKey:@"msgStatus"];
171171
//消息ID
172172
[dic setObject:[NSString stringWithFormat:@"%@", recent.lastMessage.messageId] forKey:@"messageId"];
173173
//消息内容
@@ -202,7 +202,7 @@ -(void)getResouces{
202202
if (recent.session.sessionType == NIMSessionTypeP2P) {
203203
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
204204
[dic setObject:[NSString stringWithFormat:@"%@",recent.session.sessionId] forKey:@"contactId"];
205-
[dic setObject:[NSString stringWithFormat:@"%ld", recent.session.sessionType] forKey:@"sessionType"];
205+
[dic setObject:[NSString stringWithFormat:@"%zd", recent.session.sessionType] forKey:@"sessionType"];
206206
//未读
207207
NSString *strUnreadCount = [NSString stringWithFormat:@"%ld", recent.unreadCount];
208208
allUnreadNum = allUnreadNum + [strUnreadCount integerValue];
@@ -212,9 +212,9 @@ -(void)getResouces{
212212
//账号
213213
[dic setObject:[NSString stringWithFormat:@"%@",recent.lastMessage.session.sessionId] forKey:@"account"];
214214
//消息类型
215-
[dic setObject:[NSString stringWithFormat:@"%ld", recent.lastMessage.messageType] forKey:@"msgType"];
215+
[dic setObject:[NSString stringWithFormat:@"%zd", recent.lastMessage.messageType] forKey:@"msgType"];
216216
//消息状态
217-
[dic setObject:[NSString stringWithFormat:@"%ld", recent.lastMessage.deliveryState] forKey:@"msgStatus"];
217+
[dic setObject:[NSString stringWithFormat:@"%zd", recent.lastMessage.deliveryState] forKey:@"msgStatus"];
218218
//消息ID
219219
[dic setObject:[NSString stringWithFormat:@"%@", recent.lastMessage.messageId] forKey:@"messageId"];
220220
//消息内容
@@ -233,19 +233,19 @@ -(void)getResouces{
233233
if ( [[NIMSDK sharedSDK].teamManager isMyTeam:recent.lastMessage.session.sessionId]) {
234234
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
235235
[dic setObject:[NSString stringWithFormat:@"%@",recent.session.sessionId] forKey:@"contactId"];
236-
[dic setObject:[NSString stringWithFormat:@"%ld", recent.session.sessionType] forKey:@"sessionType"];
236+
[dic setObject:[NSString stringWithFormat:@"%zd", recent.session.sessionType] forKey:@"sessionType"];
237237
//未读
238-
NSString *strUnreadCount = [NSString stringWithFormat:@"%ld", recent.unreadCount];
238+
NSString *strUnreadCount = [NSString stringWithFormat:@"%zd", recent.unreadCount];
239239
allUnreadNum = allUnreadNum + [strUnreadCount integerValue];
240240
[dic setObject:strUnreadCount forKey:@"unreadCount"];
241241
//群组名称或者聊天对象名称
242242
[dic setObject:[NSString stringWithFormat:@"%@", [self nameForRecentSession:recent] ] forKey:@"name"];
243243
//账号
244244
[dic setObject:[NSString stringWithFormat:@"%@", recent.lastMessage.from] forKey:@"account"];
245245
//消息类型
246-
[dic setObject:[NSString stringWithFormat:@"%ld", recent.lastMessage.messageType] forKey:@"msgType"];
246+
[dic setObject:[NSString stringWithFormat:@"%zd", recent.lastMessage.messageType] forKey:@"msgType"];
247247
//消息状态
248-
[dic setObject:[NSString stringWithFormat:@"%ld", recent.lastMessage.deliveryState] forKey:@"msgStatus"];
248+
[dic setObject:[NSString stringWithFormat:@"%zd", recent.lastMessage.deliveryState] forKey:@"msgStatus"];
249249
//消息ID
250250
[dic setObject:[NSString stringWithFormat:@"%@", recent.lastMessage.messageId] forKey:@"messageId"];
251251
//消息内容
@@ -255,7 +255,7 @@ -(void)getResouces{
255255

256256
[dic setObject:[NSString stringWithFormat:@"%@", [self imageUrlForRecentSession:recent] ? [self imageUrlForRecentSession:recent] : @""] forKey:@"imagePath"];
257257
NIMTeam *team = [[[NIMSDK sharedSDK] teamManager]teamById:recent.lastMessage.session.sessionId];
258-
[dic setObject:[NSString stringWithFormat:@"%ld",team.memberNumber] forKey:@"memberCount"];
258+
[dic setObject:[NSString stringWithFormat:@"%zd",team.memberNumber] forKey:@"memberCount"];
259259
NSString *strMute = team.notifyForNewMsg?@"1":@"0";
260260
[dic setObject:strMute forKey:@"mute"];
261261
[sessionList addObject:dic];

ios/RNNeteaseIm/RNNeteaseIm/RNNeteaseIm.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,10 @@ -(void)setSendState{
656656
//删除撤销消息通知
657657
[_bridge.eventDispatcher sendDeviceEventWithName:@"observeDeleteMessage" body:param];
658658
break;
659+
case 16:
660+
//资金变动通知
661+
[_bridge.eventDispatcher sendDeviceEventWithName:@"observeAccountNotice" body:param];
662+
break;
659663
default:
660664
break;
661665
}

ios/RNNeteaseIm/RNNeteaseIm/RNNotificationCenter.m

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#import <AVFoundation/AVFoundation.h>
1111
#import "NSDictionary+NTESJson.h"
1212
#import "NIMMessageMaker.h"
13+
#import "NIMModel.h"
1314
@interface RNNotificationCenter () <NIMSystemNotificationManagerDelegate,NIMChatManagerDelegate>
1415
@property (nonatomic,strong) AVAudioPlayer *player; //播放提示音
1516
@end
@@ -47,7 +48,7 @@ - (void)dealloc{
4748
[[NIMSDK sharedSDK].chatManager removeDelegate:self];
4849
}
4950
#pragma mark - NIMChatManagerDelegate
50-
- (void)onRecvMessages:(NSArray *)messages
51+
- (void)onRecvMessages:(NSArray *)messages//接收到新消息
5152
{
5253
static BOOL isPlaying = NO;
5354
if (isPlaying) {
@@ -58,7 +59,7 @@ - (void)onRecvMessages:(NSArray *)messages
5859
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
5960
isPlaying = NO;
6061
});
61-
[self checkMessageAt:messages];
62+
[self checkTranferMessage:messages];
6263
}
6364

6465
- (void)playMessageAudioTip
@@ -78,9 +79,20 @@ - (void)playMessageAudioTip
7879
// [self.player play];
7980
// }
8081
}
81-
82-
- (void)checkMessageAt:(NSArray *)messages
83-
{
82+
//检测是不是消息助手发来的转账消息提醒
83+
- (void)checkTranferMessage:(NSArray *)messages{
84+
for (NIMMessage *message in messages) {
85+
if ([message.from isEqualToString:@"10000"] && (message.messageType == NIMMessageTypeCustom)) {
86+
NIMCustomObject *customObject = message.messageObject;
87+
DWCustomAttachment *obj = customObject.attachment;
88+
if (obj && (obj.custType == CustomMessgeTypeAccountNotice)) {
89+
// NSLog(@"dataDict:%@",obj.dataDict);
90+
NIMModel *mode = [NIMModel initShareMD];
91+
mode.accountNoticeDict = obj.dataDict;
92+
93+
}
94+
}
95+
}
8496

8597
}
8698

0 commit comments

Comments
 (0)