easemob / im_flutter_sdk

环信im flutter sdk, example中包含ui代码.
MIT License
234 stars 86 forks source link

fix: android side get reactions of message null pointer error #543

Closed flowkscai closed 1 year ago

flowkscai commented 1 year ago

问题描述:

安卓下获取消息 Reaction 列表抛空指针异常

问题定位:

EMMessageWrapper.java

private void reactionList(JSONObject params, String channelName, MethodChannel.Result result) throws JSONException {
      String msgId = params.getString("msgId");
      EMMessage msg = getMessageWithId(msgId);
      ArrayList<Map<String, Object>> list = new ArrayList<>();
      if (msg != null) {
          List<EMMessageReaction> reactions = msg.getMessageReaction();  // <== 可能返回 null
          for (int i = 0; i < reactions.size(); i++) {
              list.add(EMMessageReactionHelper.toJson(reactions.get(i)));
          }
      }
      onSuccess(result, channelName, list);
  }