Skip to content

Commit 77ab8af

Browse files
committed
fix:群备注名称,
1 parent 0429d71 commit 77ab8af

File tree

2 files changed

+51
-21
lines changed

2 files changed

+51
-21
lines changed

android/src/main/java/com/netease/im/RNNeteaseImModule.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,27 @@ public void resetSystemMessageUnreadCount(final Promise promise) {
18951895
NIMClient.getService(SystemMessageService.class).resetSystemMessageUnreadCount();
18961896
}
18971897

1898+
1899+
@ReactMethod
1900+
public void getCacheSize(final Promise promise) {
1901+
FileCacheUtil.getCacheSie(new FileCacheUtil.OnObserverGet() {
1902+
@Override
1903+
public void onGetCacheSize(String size) {
1904+
promise.resolve(size);
1905+
}
1906+
});
1907+
}
1908+
1909+
@ReactMethod
1910+
public void cleanCache(final Promise promise) {
1911+
FileCacheUtil.cleanCache(new FileCacheUtil.OnObserverClean() {
1912+
1913+
@Override
1914+
public void onCleanCache(boolean succeeded) {
1915+
promise.resolve("" + succeeded);
1916+
}
1917+
});
1918+
}
18981919
void showTip(final String tip) {
18991920
handler.post(new Runnable() {
19001921
@Override

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

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
import android.support.v4.app.NotificationCompat;
77
import android.text.TextUtils;
88

9+
import com.alibaba.fastjson.JSON;
10+
import com.alibaba.fastjson.JSONObject;
911
import com.netease.im.IMApplication;
1012
import com.netease.im.session.extension.RedPacketOpenAttachement;
13+
import com.netease.im.uikit.common.util.log.LogUtil;
1114
import com.netease.nimlib.sdk.NIMClient;
1215
import com.netease.nimlib.sdk.msg.MessageBuilder;
1316
import com.netease.nimlib.sdk.msg.MsgService;
@@ -88,6 +91,7 @@ public static void sendAddFriendNotification(String account, String content) {
8891
}
8992

9093
public static void receiver(NotificationManager manager, CustomNotification customNotification) {
94+
LogUtil.i("SessionUtil", customNotification.getFromAccount());
9195
Map<String, Object> map = customNotification.getPushPayload();
9296
if (map != null && map.containsKey("type")) {
9397
String type = (String) map.get("type");
@@ -101,32 +105,37 @@ public static void receiver(NotificationManager manager, CustomNotification cust
101105
builder.setContentIntent(contentIntent);
102106
builder.setSmallIcon(IMApplication.getNotify_msg_drawable_id());
103107
manager.notify((int) System.currentTimeMillis(), builder.build());
104-
} else if (SessionUtil.CUSTOM_Notification_redpacket_open.equals(type)) {
105-
Map<String, Object> data = (Map<String, Object>) map.get("data");
106-
107-
Map<String, Object> dict = (Map<String, Object>) data.get("dict");
108-
String sendId = (String) dict.get("sendId");
109-
String openId = (String) dict.get("openId");
110-
String hasRedPacket = (String) dict.get("hasRedPacket");
111-
String serialNo = (String) dict.get("serialNo");
112-
113-
String timestamp = (String) data.get("timestamp");
114-
long t = 0L;
115-
try {
116-
t = Long.parseLong(timestamp);
117-
} catch (NumberFormatException e) {
118-
t = System.currentTimeMillis() / 1000;
119-
e.printStackTrace();
120-
}
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+
}
121128
// LogUtil.i("timestamp","timestamp:"+timestamp);
122129
// LogUtil.i("timestamp","t:"+t);
123130
// LogUtil.i("timestamp",""+data);
124-
String sessionId = (String) data.get("sessionId");
125-
String sessionType = (String) data.get("sessionType");
126-
final String id = getSessionType(sessionType) == SessionTypeEnum.P2P ? openId : sessionId;
127-
sendRedPacketOpenLocal(id, getSessionType(sessionType), sendId, openId, hasRedPacket, serialNo, t);
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+
}
128136
}
129137
}
138+
130139
}
131140

132141
/**

0 commit comments

Comments
 (0)