showNotification method

Future<void> showNotification(
  1. int id,
  2. String title,
  3. String body,
  4. String? payload,
)

Implementation

Future<void> showNotification(
    int id, String title, String body, String? payload) async {
  const AndroidNotificationDetails androidNotificationDetails =
  AndroidNotificationDetails(
    'your_channel_id',
    'your_channel_name',
    channelDescription: 'your_channel_description',
    importance: Importance.max,
    priority: Priority.high,
  );

  const NotificationDetails notificationDetails = NotificationDetails(
      android: androidNotificationDetails,
      iOS: DarwinNotificationDetails());

  if (await getNotificationStatus()) { // Use the private method
    await flutterLocalNotificationsPlugin.show(
        id, title, body, notificationDetails,
        payload: payload);
  } else {
    AppLogs.showInfoLogs('Notification not sent');
  }
}