createMessageNotification method
Creates a message notification template for chat applications.
Implementation
NotificationPayload createMessageNotification({
required String id,
required String senderName,
required String message,
String? senderAvatar,
String? conversationId,
String? threadIdentifier,
Map<String, dynamic>? data,
}) {
return NotificationPayload(
id: id,
title: senderName,
body: message,
data: <String, dynamic>{
'type': 'message',
'conversationId': conversationId,
'senderId': senderName,
...?data,
},
largeIcon: senderAvatar,
threadIdentifier: threadIdentifier ?? conversationId,
importance: NotificationImportance.high,
priority: NotificationPriority.high,
category: 'msg',
actions: const <NotificationAction>[
NotificationAction(
id: 'reply',
title: 'Reply',
inputs: <NotificationActionInput>[
NotificationActionInput(
id: 'reply_text',
title: 'Reply',
placeholder: 'Type your reply...',
),
],
),
NotificationAction(id: 'mark_read', title: 'Mark as Read'),
],
);
}