Skip to content

Commit ba17101

Browse files
authored
Merge pull request #469 from easemob/flutter2_dev
Flutter2 dev
2 parents 5886702 + f8f8c91 commit ba17101

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

android/src/main/java/com/easemob/im_flutter_sdk/EMHelper.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,44 @@ static Map<String, Object> toJson(EMMessage message) {
526526
}
527527

528528
if (message.ext().size() > 0 && null != message.ext()) {
529-
data.put("attributes", message.ext());
529+
HashMap<String, Object> map = new HashMap<>();
530+
for (Map.Entry entry:message.ext().entrySet()) {
531+
String key = entry.getKey().toString();
532+
try {
533+
JSONObject value = message.getJSONObjectAttribute(key);
534+
map.put(key, value);
535+
continue;
536+
}
537+
catch (HyphenateException e) {
538+
}
539+
try {
540+
boolean value = message.getBooleanAttribute(key);
541+
map.put(key, value);
542+
continue;
543+
} catch (HyphenateException e) {
544+
}
545+
546+
try {
547+
JSONArray value = message.getJSONArrayAttribute(key);
548+
map.put(key, value);
549+
continue;
550+
} catch (HyphenateException e) {
551+
}
552+
try {
553+
int value = message.getIntAttribute(key);
554+
map.put(key, value);
555+
continue;
556+
} catch (HyphenateException e){
557+
}
558+
559+
try {
560+
String value = message.getStringAttribute(key);
561+
map.put(key, value);
562+
continue;
563+
} catch (HyphenateException e) {
564+
}
565+
}
566+
data.put("attributes", map);
530567
}
531568
data.put("from", message.getFrom());
532569
data.put("to", message.getTo());

0 commit comments

Comments
 (0)