createCustomMessage static method

Future<V2TimValueCallback<V2TimMsgCreateInfoResult>> createCustomMessage({
  1. required String data,
  2. String desc = "",
  3. String extension = "",
})

Implementation

static Future<V2TimValueCallback<V2TimMsgCreateInfoResult>> createCustomMessage({
  required String data,
  String desc = "",
  String extension = "",
}) async {
  Map<String, dynamic> message = Tools.createNativeMessage(
    elem: List<Map<String, dynamic>>.from([
      Map<String, dynamic>.from({
        "elem_type": Tools.dartElemTypeToNative(MessageElemType.V2TIM_ELEM_TYPE_CUSTOM),
        "custom_elem_data": data,
        "custom_elem_desc": desc,
        "custom_elem_ext": extension,
      })
    ]),
  );
  String key = Tools.generateUniqueString();
  createdMessage[key] = message;

  return V2TimValueCallback<V2TimMsgCreateInfoResult>.fromJson({
    "code": 0,
    "desc": "success",
    "data": Map<String, dynamic>.from({"id": key, "messageInfo": (await Tools.convertMessage2Dart(message)).toJson()})
  });
}