|
6 | 6 | import com.facebook.react.bridge.WritableMap; |
7 | 7 | import com.netease.im.RNNeteaseImModule; |
8 | 8 | import com.netease.im.ReactCache; |
| 9 | +import com.netease.im.session.extension.AccountNoticeAttachment; |
| 10 | +import com.netease.im.session.extension.CustomAttachment; |
| 11 | +import com.netease.im.session.extension.CustomAttachmentType; |
9 | 12 | import com.netease.im.uikit.cache.SimpleCallback; |
10 | 13 | import com.netease.im.uikit.cache.TeamDataCache; |
11 | 14 | import com.netease.nimlib.sdk.NIMClient; |
|
16 | 19 | import com.netease.nimlib.sdk.auth.constant.LoginSyncStatus; |
17 | 20 | import com.netease.nimlib.sdk.msg.MsgService; |
18 | 21 | import com.netease.nimlib.sdk.msg.MsgServiceObserve; |
| 22 | +import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum; |
19 | 23 | import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum; |
20 | 24 | import com.netease.nimlib.sdk.msg.model.IMMessage; |
21 | 25 | import com.netease.nimlib.sdk.msg.model.RecentContact; |
@@ -227,7 +231,29 @@ public int compare(RecentContact o1, RecentContact o2) { |
227 | 231 |
|
228 | 232 | @Override |
229 | 233 | public void onEvent(List<IMMessage> imMessages) { |
230 | | - |
| 234 | + if (imMessages == null || imMessages.isEmpty()) { |
| 235 | + return; |
| 236 | + } |
| 237 | + for (IMMessage m : imMessages) { |
| 238 | + if (m.getMsgType() == MsgTypeEnum.custom) { |
| 239 | + CustomAttachment attachment = null; |
| 240 | + try { |
| 241 | + attachment = (CustomAttachment) m.getAttachment(); |
| 242 | + } catch (Exception e) { |
| 243 | + e.printStackTrace(); |
| 244 | + } |
| 245 | + if (attachment != null && attachment.getType() == CustomAttachmentType.AccountNotice) { |
| 246 | + AccountNoticeAttachment noticeAttachment = null; |
| 247 | + try { |
| 248 | + noticeAttachment = (AccountNoticeAttachment) attachment; |
| 249 | + } catch (Exception e) { |
| 250 | + e.printStackTrace(); |
| 251 | + } |
| 252 | + ReactCache.emit(ReactCache.observeAccountNotice, noticeAttachment == null ? null : noticeAttachment.toReactNative()); |
| 253 | + break; |
| 254 | + } |
| 255 | + } |
| 256 | + } |
231 | 257 | } |
232 | 258 | }; |
233 | 259 | Observer<List<RecentContact>> messageObserver = new Observer<List<RecentContact>>() { |
@@ -301,7 +327,7 @@ public void onEvent(StatusCode code) { |
301 | 327 | } |
302 | 328 | WritableMap r = Arguments.createMap(); |
303 | 329 | String codeValue; |
304 | | - switch (code){ |
| 330 | + switch (code) { |
305 | 331 | case PWD_ERROR: |
306 | 332 | codeValue = "10"; |
307 | 333 | break; |
|
0 commit comments