showTextNotification method
Implementation
Future<void> showTextNotification(
String title, String message, String msgid, String redirectUrl) async {
await createNotificationChannel();
if (redirectUrl == null ||
redirectUrl.isEmpty ||
!Uri.parse(redirectUrl).isAbsolute) {
redirectUrl = "https://www.leewaysoftech.com/";
}
int requestCode = msgid.hashCode;
const NotificationDetails platformChannelSpecifics = NotificationDetails(
android: AndroidNotificationDetails(
CHANNEL_ID,
'Personal Notifications',
channelDescription: 'Description of personal notifications',
importance: Importance.max,
priority: Priority.high,
playSound: true,
icon: '@mipmap/notify_adaptive_fore',
),
);
// Store msgid, redirectUrl, and type in the payload for later retrieval
String payload = jsonEncode({
'url': redirectUrl,
'msgid': msgid,
'type': 'Text' // Include the type here
});
await flutterLocalNotificationsPlugin.show(
requestCode,
title,
message,
platformChannelSpecifics,
payload: payload, // Pass JSON string as payload
);
}