sendInteractiveMessage static method
Future<InteractiveMessage?>
sendInteractiveMessage(
- InteractiveMessage message, {
- required dynamic onSuccess(
- InteractiveMessage message
- required dynamic onError(
- CometChatException excep
send Interactive messages which has to change its state according to some interactions.
The method could throw PlatformException with error codes specifying the cause
Implementation
static Future<InteractiveMessage?> sendInteractiveMessage(
InteractiveMessage message,
{required Function(InteractiveMessage message)? onSuccess,
required Function(CometChatException excep)? onError}) async {
try {
final result = await channel.invokeMethod('sendInteractiveMessage', {
'receiverId': message.receiverUid,
'type': message.type,
'receiverType': message.receiverType,
'interactiveData': message.interactiveData,
'interactionGoal': message.interactionGoal?.toMap(),
'muid': message.muid,
'parentMessageId': message.parentMessageId,
'metadata': json.encode(
message.metadata ?? {},
),
'tags': message.tags,
'allowSenderInteraction': message.allowSenderInteraction,
});
final res = InteractiveMessage.fromMap(result);
if (onSuccess != null) onSuccess(res);
return res;
} on PlatformException catch (p) {
_errorCallbackHandler(null, p, null, onError);
} catch (e) {
_errorCallbackHandler(null, null, e, onError);
}
return null;
}