Skip to content

Commit b6e761c

Browse files
committed
fix:拆红包解析
1 parent 3f80180 commit b6e761c

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

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)