Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion android/src/main/java/com/easemob/im_flutter_sdk/EMHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,44 @@ static Map<String, Object> toJson(EMMessage message) {
}

if (message.ext().size() > 0 && null != message.ext()) {
data.put("attributes", message.ext());
HashMap<String, Object> map = new HashMap<>();
for (Map.Entry entry:message.ext().entrySet()) {
String key = entry.getKey().toString();
try {
JSONObject value = message.getJSONObjectAttribute(key);
map.put(key, value);
continue;
}
catch (HyphenateException e) {
}
try {
boolean value = message.getBooleanAttribute(key);
map.put(key, value);
continue;
} catch (HyphenateException e) {
}

try {
JSONArray value = message.getJSONArrayAttribute(key);
map.put(key, value);
continue;
} catch (HyphenateException e) {
}
try {
int value = message.getIntAttribute(key);
map.put(key, value);
continue;
} catch (HyphenateException e){
}

try {
String value = message.getStringAttribute(key);
map.put(key, value);
continue;
} catch (HyphenateException e) {
}
}
data.put("attributes", map);
}
data.put("from", message.getFrom());
data.put("to", message.getTo());
Expand Down