Skip to content

Commit b09e851

Browse files
guangyaoguangyao
authored andcommitted
2 parents ca5afbd + a5f5579 commit b09e851

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

android/src/main/java/com/netease/im/session/SessionService.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,14 @@ public void onIncomingMessage(@NonNull List<IMMessage> messages) {
135135
updateShowTimeItem(addedListItems, false);
136136
}
137137
List<IMMessage> r = onQuery(addedListItems);
138-
if (!this.mute && r.size() > 0) {
139-
AudioPlayService.getInstance().playAudio(handler, ReactCache.getReactContext(), AudioManager.STREAM_RING, "raw", "msg");
138+
if (r.size() > 0) {
139+
IMMessage m = messages.get(0);
140+
if (!this.mute && m.getDirect() == MsgDirectionEnum.In) {
141+
if(!(m.getMsgType() == MsgTypeEnum.notification||m.getMsgType() == MsgTypeEnum.tip)){
142+
AudioPlayService.getInstance().playAudio(handler, ReactCache.getReactContext(), AudioManager.STREAM_RING, "raw", "msg");
143+
}
144+
145+
}
140146
}
141147
refreshMessageList(r);
142148

android/src/main/java/com/netease/im/session/SessionUtil.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static void sendAddFriendNotification(String account, String content) {
9191
}
9292

9393
public static void receiver(NotificationManager manager, CustomNotification customNotification) {
94-
LogUtil.i("SessionUtil", customNotification.getFromAccount());
94+
LogUtil.i("SessionUtil", customNotification.getContent());
9595
Map<String, Object> map = customNotification.getPushPayload();
9696
if (map != null && map.containsKey("type")) {
9797
String type = (String) map.get("type");
@@ -105,34 +105,34 @@ public static void receiver(NotificationManager manager, CustomNotification cust
105105
builder.setContentIntent(contentIntent);
106106
builder.setSmallIcon(IMApplication.getNotify_msg_drawable_id());
107107
manager.notify((int) System.currentTimeMillis(), builder.build());
108-
} else {
109-
String content = customNotification.getContent();
110-
if (!TextUtils.isEmpty(content)) {
111-
JSONObject object = JSON.parseObject(content);
112-
JSONObject data = object.getJSONObject("data");
113-
114-
JSONObject dict = data.getJSONObject("dict");
115-
String sendId = dict.getString("sendId");
116-
String openId = dict.getString("openId");
117-
String hasRedPacket = dict.getString("hasRedPacket");
118-
String serialNo = dict.getString("serialNo");
119-
120-
String timestamp = data.getString("timestamp");
121-
long t = 0L;
122-
try {
123-
t = Long.parseLong(timestamp);
124-
} catch (NumberFormatException e) {
125-
t = System.currentTimeMillis() / 1000;
126-
e.printStackTrace();
127-
}
108+
}
109+
} else {
110+
String content = customNotification.getContent();
111+
if (!TextUtils.isEmpty(content)) {
112+
JSONObject object = JSON.parseObject(content);
113+
JSONObject data = object.getJSONObject("data");
114+
115+
JSONObject dict = data.getJSONObject("dict");
116+
String sendId = dict.getString("sendId");
117+
String openId = dict.getString("openId");
118+
String hasRedPacket = dict.getString("hasRedPacket");
119+
String serialNo = dict.getString("serialNo");
120+
121+
String timestamp = data.getString("timestamp");
122+
long t = 0L;
123+
try {
124+
t = Long.parseLong(timestamp);
125+
} catch (NumberFormatException e) {
126+
t = System.currentTimeMillis() / 1000;
127+
e.printStackTrace();
128+
}
128129
// LogUtil.i("timestamp","timestamp:"+timestamp);
129130
// LogUtil.i("timestamp","t:"+t);
130131
// LogUtil.i("timestamp",""+data);
131-
String sessionId = (String) data.get("sessionId");
132-
String sessionType = (String) data.get("sessionType");
133-
final String id = getSessionType(sessionType) == SessionTypeEnum.P2P ? openId : sessionId;
134-
sendRedPacketOpenLocal(id, getSessionType(sessionType), sendId, openId, hasRedPacket, serialNo, t);
135-
}
132+
String sessionId = data.getString("sessionId");
133+
String sessionType = data.getString("sessionType");
134+
final String id = getSessionType(sessionType) == SessionTypeEnum.P2P ? openId : sessionId;
135+
sendRedPacketOpenLocal(id, getSessionType(sessionType), sendId, openId, hasRedPacket, serialNo, t);
136136
}
137137
}
138138

0 commit comments

Comments
 (0)