Skip to content

Commit 5106f10

Browse files
guangyaoguangyao
authored andcommitted
Fix 网络异常而导致崩溃的问题
1 parent d419145 commit 5106f10

File tree

2 files changed

+48
-12
lines changed

2 files changed

+48
-12
lines changed

ios/RNNeteaseIm/RNNeteaseIm/NIMModel.m

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,92 +28,127 @@ +(instancetype)initShareMD{
2828
- (void)setRecentDict:(NSDictionary *)recentDict{
2929
if ((_recentDict != recentDict)&&(recentDict.count)) {
3030
_recentDict = recentDict;
31-
self.myBlock(1, recentDict);
31+
if (self.myBlock) {
32+
self.myBlock(1, recentDict);
33+
}
3234
}
3335
}
3436

3537
-(void)setNetStatus:(NSString *)NetStatus{
3638
if ((_NetStatus != NetStatus)&&(NetStatus.length)) {
3739
_NetStatus = NetStatus;
38-
self.myBlock(0, NetStatus);
40+
if (self.myBlock) {
41+
self.myBlock(0, NetStatus);
42+
}
3943
}
4044
}
4145
-(void)setNIMKick:(NSString *)NIMKick{
4246
if ((_NIMKick != NIMKick)&&(NIMKick.length)) {
4347
_NIMKick = NIMKick;
44-
self.myBlock(2, NIMKick);
48+
if (self.myBlock) {
49+
self.myBlock(2, NIMKick);
50+
}
4551
}
4652
}
4753
-(void)setContactList:(NSMutableDictionary *)contactList{
4854
if (_contactList != contactList) {
4955
_contactList = contactList;
50-
self.myBlock(3, contactList);
56+
if (self.myBlock) {
57+
self.myBlock(3, contactList);
58+
}
5159
}
5260
}
5361
-(void)setNotiArr:(NSMutableArray *)notiArr{
5462
if (_notiArr != notiArr) {
5563
_notiArr = notiArr;
56-
self.myBlock(5, notiArr);
64+
if (self.myBlock) {
65+
self.myBlock(5, notiArr);
66+
}
5767
}
5868
}
5969
-(void)setTeamArr:(NSMutableArray *)teamArr{
70+
if (self.myBlock) {
6071
self.myBlock(4, teamArr);
72+
}
6173
}
6274
//未读条数
6375
-(void)setUnreadCount:(NSInteger)unreadCount{
64-
self.myBlock(6, [NSString stringWithFormat:@"%ld",unreadCount]);
76+
if (self.myBlock) {
77+
self.myBlock(6, [NSString stringWithFormat:@"%ld",unreadCount]);
78+
}
79+
6580
}
6681
//
6782
-(void)setResorcesArr:(NSMutableArray *)ResorcesArr{
83+
if (self.myBlock) {
6884
self.myBlock(7, ResorcesArr);
85+
}
6986
}
7087
//开始发送
7188
-(void)setStartSend:(NSDictionary *)startSend{
7289
if (startSend.count) {
73-
self.myBlock(8, startSend);
90+
if (self.myBlock) {
91+
self.myBlock(8, startSend);
92+
}
7493
}
7594
}
7695
//结束发送
7796
-(void)setEndSend:(NSDictionary *)endSend{
7897
if (endSend.count) {
79-
self.myBlock(9, endSend);
98+
if (self.myBlock) {
99+
self.myBlock(9, endSend);
100+
}
80101
}
81102
}
82103
//发送进度(图片等附件)
83104
-(void)setProcessSend:(NSDictionary *)processSend{
84105
if (processSend.count) {
85-
self.myBlock(10, processSend);
106+
if (self.myBlock) {
107+
self.myBlock(10, processSend);
108+
}
86109
}
87110
}
88111
//已读通知
89112
-(void)setReceipt:(NSString *)receipt{
90113
if (receipt.length) {
91-
self.myBlock(11, receipt);
114+
if (self.myBlock) {
115+
self.myBlock(11, receipt);
116+
}
92117
}
93118
}
94119
//发送消息
95120
-(void)setSendState:(NSMutableArray *)sendState{
96121
if (_sendState != sendState) {
122+
if (self.myBlock) {
97123
self.myBlock(12, sendState);
124+
}
125+
98126
}
99127
}
100128
//黑名单列表
101129
-(void)setBankList:(NSMutableArray *)bankList{
102130
if (bankList.count) {
131+
if (self.myBlock) {
103132
self.myBlock(13, bankList);
133+
}
134+
104135
}
105136
}
106137

107138
//录音进度
108139
-(void)setAudioDic:(NSDictionary *)audioDic{
109140
if (audioDic.count) {
110-
self.myBlock(14, audioDic);
141+
if (self.myBlock) {
142+
self.myBlock(14, audioDic);
143+
}
111144
}
112145
}
113146

114147
- (void)setDeleteMessDict:(NSDictionary *)deleteMessDict{
115148
if (deleteMessDict.count) {
116-
self.myBlock(15, deleteMessDict);
149+
if (self.myBlock) {
150+
self.myBlock(15, deleteMessDict);
151+
}
117152
}
118153
}
119154

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
[[NoticeViewController initWithNoticeViewController]initWithDelegate];
32+
[[RNNotificationCenter sharedCenter] start];
3233
//请将 NIMMyAccount 以及 NIMMyToken 替换成您自己提交到此App下的账号和密码
3334
[[NIMSDK sharedSDK].loginManager login:account token:token completion:^(NSError *error) {
3435
if (!error) {

0 commit comments

Comments
 (0)