showTextNotification method

Future<void> showTextNotification(
  1. String title,
  2. String message,
  3. String msgid,
  4. String redirectUrl,
)

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(
      channelID,
      'Personal Notifications',
      channelDescription: 'Description of personal notifications',
      importance: Importance.max,
      priority: Priority.high,
      playSound: true,
      icon: '@mipmap/notify_adaptive_fore',
    ),
  );
  String payload =
      jsonEncode({'url': redirectUrl, 'msgid': msgid, 'type': 'Text'});

  await flutterLocalNotificationsPlugin.show(
    requestCode,
    title,
    message,
    platformChannelSpecifics,
    payload: payload,
  );
}