sendMessage method Null safety
- {required String id,
- required String receiver,
- required String groupID,
- MessagePriorityEnum priority = MessagePriorityEnum.V2TIM_PRIORITY_NORMAL,
- bool onlineUserOnly = false,
- bool isExcludedFromUnreadCount = false,
- bool needReadReceipt = false,
- OfflinePushInfo? offlinePushInfo,
- String? cloudCustomData,
- String? localCustomData}
Send message Parameters
The id message uniquely identifies
receiver the userID of the message recipient. If you are sending a C2C single-chat message, you only need to specify the receiver.
groupID target group ID, if you are sending group chat messages, you only need to specify groupID.
priority Message priority, only valid for group chat messages. Please set important messages to high priority (such as red envelopes, gift messages), and frequent and unimportant messages to low priority (such as like messages).
onlineUserOnly Whether only online users can receive it, if it is set to true, the receiver's historical messages cannot be pulled. It is often used to implement weak prompts such as 'the other party is typing' or non-important prompts in groups. Field does not support AVChatRoom.
offlinePushInfo The title and content of offline push.
needReadReceipt whether a read receipt is required for messages (only Group messages are valid, supported by version 6.1 and above, you need to purchase the Ultimate Edition package)
Implementation
Future<V2TimValueCallback<V2TimMessage>> sendMessage(
{required String id, // ID created by myself
required String receiver,
required String groupID,
MessagePriorityEnum priority = MessagePriorityEnum.V2TIM_PRIORITY_NORMAL,
bool onlineUserOnly = false,
bool isExcludedFromUnreadCount = false,
bool needReadReceipt = false,
OfflinePushInfo? offlinePushInfo,
String? cloudCustomData, // Add before message sending
String? localCustomData}) async {
return ImFlutterPlatform.instance.sendMessage(
id: id,
receiver: receiver,
groupID: groupID,
priority: EnumUtils.convertMessagePriorityEnum(priority) ,
onlineUserOnly: onlineUserOnly,
isExcludedFromUnreadCount: isExcludedFromUnreadCount,
offlinePushInfo: offlinePushInfo?.toJson(),
localCustomData: localCustomData,
needReadReceipt: needReadReceipt,
cloudCustomData: cloudCustomData);
}