Skip to content

Commit 0241639

Browse files
committed
Merge branch 'master' of github.com:reactnativecomponent/react-native-netease-im
2 parents e970309 + 72d6668 commit 0241639

File tree

7 files changed

+35
-8
lines changed

7 files changed

+35
-8
lines changed

NIM.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ export default class NIM{
156156
*/
157157
static playLocacl(name,type){
158158
if(Platform.OS === 'ios'){
159-
return RNNeteaseIm.playLocacl(name,type);
159+
return RNNeteaseIm.playLocal(name,type);
160160
}
161-
return RNNeteaseIm.playLocacl("assets://"+name,type);
161+
return RNNeteaseIm.playLocal("assets://"+name,type);
162162
}
163163
/**
164164
* 停止播放录音

ios/RNNeteaseIm/RNNeteaseIm/ConversationViewController.m

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ @interface ConversationViewController ()<NIMMediaManagerDelegate,NIMMediaManager
2626
NSMutableArray *_sessionArr;
2727

2828
}
29+
@property (nonatomic,strong) AVAudioPlayer *player; //播放提示音
2930

3031
@end
3132

@@ -34,6 +35,7 @@ @implementation ConversationViewController
3435
- (void)viewDidLoad {
3536
[super viewDidLoad];
3637
// Do any additional setup after loading the view.
38+
3739
}
3840

3941
+(instancetype)initWithConversationViewController{
@@ -46,6 +48,15 @@ +(instancetype)initWithConversationViewController{
4648
return conVC;
4749
}
4850

51+
- (instancetype)init {
52+
self = [super init];
53+
if(self) {
54+
NSURL *url = [[NSBundle mainBundle] URLForResource:@"message" withExtension:@"wav"];
55+
_player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
56+
}
57+
return self;
58+
}
59+
4960
-(void)startSession:(NSString *)sessionID withType:(NSString *)type{
5061
_sessionID = sessionID;
5162
_type = type;
@@ -509,8 +520,10 @@ - (void)onRecvMessages:(NSArray *)messages
509520
completion:nil];
510521
//标记已读消息
511522
[[NIMSDK sharedSDK].conversationManager markAllMessagesReadInSession:_session];
523+
[self.player stop];
524+
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error:nil];
525+
[self.player play];
512526
}
513-
514527
}
515528

516529

ios/RNNeteaseIm/RNNeteaseIm/NIMModel.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ -(void)setNotiArr:(NSMutableArray *)notiArr{
5454
self.myBlock(5, notiArr);
5555
}
5656
-(void)setTeamArr:(NSMutableArray *)teamArr{
57-
self.myBlock(4, teamArr);
57+
if (teamArr.count) {
58+
self.myBlock(4, teamArr);
59+
}
5860
}
5961
//未读条数
6062
-(void)setUnreadCount:(NSInteger)unreadCount{

ios/RNNeteaseIm/RNNeteaseIm/NIMViewController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ typedef void(^ERROR)(NSString *error);
1818
//获取最近聊天列表回调
1919
-(void)getRecentContactListsuccess:(SUCCESS)suc andError:(ERROR)err;
2020
-(void)addDelegate;
21+
- (void)getResouces;
2122
@end

ios/RNNeteaseIm/RNNeteaseIm/NIMViewController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ - (void)viewDidLoad {
3838
[super viewDidLoad];
3939
// Do any additional setup after loading the view.
4040
}
41+
4142
//监听网络
4243
#pragma mark - NIMLoginManagerDelegate
4344
- (void)onLogin:(NIMLoginStep)step{

ios/RNNeteaseIm/RNNeteaseIm/RNNeteaseIm.m

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,30 @@ - (dispatch_queue_t)methodQueue
219219
}
220220
//开启/关闭群组消息提醒
221221
RCT_EXPORT_METHOD(setTeamNotify:(nonnull NSString *)teamId needNotify:(nonnull NSString *)needNotify resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject){
222+
__weak typeof(self)weakSelf = self;
222223
[[TeamViewController initWithTeamViewController]muteTeam:teamId mute:needNotify Succ:^(id param) {
223224
resolve(param);
225+
[weakSelf updateMessageList];
224226
} Err:^(id erro) {
225227
reject(@"-1",erro,nil);
226228
}];
227229
}
228230
//好友消息提醒开关
229231
RCT_EXPORT_METHOD(setMessageNotify:(nonnull NSString *)contactId needNotify:(nonnull NSString *)needNotify resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject){
232+
__weak typeof(self)weakSelf = self;
230233
[[ConversationViewController initWithConversationViewController]muteMessage:contactId mute:needNotify Succ:^(id param) {
231234
resolve(param);
235+
[weakSelf updateMessageList];
232236
} Err:^(id erro) {
233237
reject(@"-1",erro,nil);
234238
}];
235239
}
240+
//刷新最近会话列表
241+
- (void)updateMessageList{
242+
[[NIMViewController initWithController]getResouces];
243+
NSLog(@"---updateMessageList");
244+
}
245+
236246
//解散群
237247
RCT_EXPORT_METHOD(dismissTeam:(nonnull NSString *)teamId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject){
238248
[[TeamViewController initWithTeamViewController] dismissTeam:teamId Succ:^(id param) {
@@ -398,7 +408,7 @@ - (dispatch_queue_t)methodQueue
398408
[[ConversationViewController initWithConversationViewController]play:filepath];
399409
}
400410
//播放本地资源录音
401-
RCT_EXPORT_METHOD(playLocacl:(nonnull NSString *)name type:(nonnull NSString *)type){
411+
RCT_EXPORT_METHOD(playLocal:(nonnull NSString *)name type:(nonnull NSString *)type){
402412
NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:type];
403413
[[ConversationViewController initWithConversationViewController]play:path];
404414
}
@@ -479,8 +489,7 @@ - (dispatch_queue_t)methodQueue
479489

480490
NSString *allSize = [NSString stringWithFormat:@"%f",docSize+libSize+tmpNimSize+tmpPickSize];
481491
NSLog(@"allSize:%@ documentPath:%@",allSize,documentPath);
482-
NSArray *events = @[allSize];
483-
resolve(events);
492+
resolve(allSize);
484493
}
485494

486495
//清除数据缓存

ios/RNNeteaseIm/RNNeteaseIm/RNNotificationCenter.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ - (void)playMessageAudioTip
8181

8282
- (void)checkMessageAt:(NSArray *)messages
8383
{
84-
}
84+
85+
}
8586

8687
#pragma mark - NIMSystemNotificationManagerDelegate
8788
- (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification{//接收自定义通知

0 commit comments

Comments
 (0)