sendMessage method

Future<V2TimValueCallback<V2TimMessage>> sendMessage({
  1. required String id,
  2. required String receiver,
  3. required String groupID,
  4. MessagePriorityEnum? priority = MessagePriorityEnum.V2TIM_PRIORITY_NORMAL,
  5. bool onlineUserOnly = false,
  6. bool isExcludedFromUnreadCount = false,
  7. bool isExcludedFromLastMessage = false,
  8. bool? isSupportMessageExtension = false,
  9. bool needReadReceipt = false,
  10. OfflinePushInfo? offlinePushInfo,
  11. String? cloudCustomData,
  12. String? localCustomData,
})

发送消息 参数

id	消息唯一标识
receiver	消息接收者的 userID, 如果是发送 C2C 单聊消息,只需要指定 receiver 即可。
groupID	目标群组 ID,如果是发送群聊消息,只需要指定 groupID 即可。
priority	消息优先级,仅针对群聊消息有效。请把重要消息设置为高优先级(比如红包、礼物消息),高频且不重要的消息设置为低优先级(比如点赞消息)。
onlineUserOnly	是否只有在线用户才能收到,如果设置为 true ,接收方历史消息拉取不到,常被用于实现“对方正在输入”或群组里的非重要提示等弱提示功能,该字段不支持 AVChatRoom。
offlinePushInfo	离线推送时携带的标题和内容。
needReadReceipt 消息是否需要已读回执(只有 Group 消息有效,6.1 及以上版本支持,需要您购买旗舰版套餐)

Implementation

Future<V2TimValueCallback<V2TimMessage>> sendMessage({
  required String id, // 自己创建的ID
  required String receiver,
  required String groupID,
  MessagePriorityEnum? priority = MessagePriorityEnum.V2TIM_PRIORITY_NORMAL,
  bool onlineUserOnly = false,
  bool isExcludedFromUnreadCount = false,
  bool isExcludedFromLastMessage = false,
  bool? isSupportMessageExtension = false,
  bool needReadReceipt = false,
  OfflinePushInfo? offlinePushInfo,
  String? cloudCustomData, // 云自定义消息字段,只能在消息发送前添加
  String? localCustomData,
}) async {
  return ImFlutterPlatform.instance.sendMessage(
    id: id,
    receiver: receiver,
    groupID: groupID,
    priority: priority!.index,
    onlineUserOnly: onlineUserOnly,
    isExcludedFromUnreadCount: isExcludedFromUnreadCount,
    isExcludedFromLastMessage: isExcludedFromLastMessage,
    isSupportMessageExtension: isSupportMessageExtension,
    offlinePushInfo: offlinePushInfo?.toJson(),
    localCustomData: localCustomData,
    needReadReceipt: needReadReceipt,
    cloudCustomData: cloudCustomData,
  );
}