File tree Expand file tree Collapse file tree 1 file changed +38
-1
lines changed
android/src/main/java/com/easemob/im_flutter_sdk Expand file tree Collapse file tree 1 file changed +38
-1
lines changed Original file line number Diff line number Diff 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 ());
You can’t perform that action at this time.
0 commit comments