0
votes

I have integrated firebase for push notifications in flutter. If the app is in foreground I have displayed a dialog with notification details. I am receiving notifications properly in android. Also in iOS notifications are working fine in background and when device is locked. I have enabled push notifications and background fetch as well. Any solution for this? Has anybody faced such issue?

I am using this firebase plugin https://pub.dev/packages/firebase_messaging

1

1 Answers

0
votes
  1. import UserNotifications in AppDelegate.

  2. UNUserNotificationCenter.current().delegate = self in didFinishLaunch

  3. Implement the below the method in AppDelegate.

func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping(UNNotificationPresentationOptions) -> Void) { print("Push notification received in foreground.") completionHandler([.alert, .sound, .badge]) }