showForegroundNotification static method

void showForegroundNotification(
  1. {required RemoteMessage remoteMessage,
  2. bool playSound = true,
  3. bool showBadge = true}
)

Implementation

static void showForegroundNotification({
  required RemoteMessage remoteMessage,
  bool playSound = true,
  bool showBadge = true,
}) async {
  await flutterLocalNotificationsPlugin.show(
    remoteMessage.hashCode,
    remoteMessage.notification?.title,
    remoteMessage.notification?.body,
    NotificationDetails(
      android: AndroidNotificationDetails(
        'default_notification_channel_id',
        'Default Notification Channel Id',
        playSound: playSound,
        channelShowBadge: showBadge,
        importance: Importance.max,
        priority: Priority.max,
      ),
      iOS: DarwinNotificationDetails(
        presentSound: playSound,
        presentBadge: showBadge,
      ),
    ),
    payload: json.encode(
      remoteMessage.data,
    ),
  );
}