Background notifications not working on iOS with Flutter package firebase_messaging
As @ChyperX suggested, this article was helpful https://medium.com/@jun.chenying/flutter-tutorial-part3-push-notification-with-firebase-cloud-messaging-fcm-2fbdd84d3a5e. Using:
<key>FirebaseAppDelegateProxyEnabled</key>
<string>NO</string>
in Info.plist instead of my previous attempts did the trick.
ivanacorovic
Updated on December 25, 2022Comments
-
ivanacorovic over 1 year
I've come across many questions like this on StackOverflow and Github, but I haven't found the answer.
I have an Apple development profile, and I've uploaded APNs Auth Key to Firebase.
I have enabled Background fetch, Remote notifications and Background processing, as well as Push Notifications in my xCode.
I have added this two pieces of code to AppDelegate.swift:
import Firebase if FirebaseApp.app() == nil { FirebaseApp.configure() } ... if #available(iOS 10.0, *) { // For iOS 10 display notification (sent via APNS) UNUserNotificationCenter.current().delegate = self let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] UNUserNotificationCenter.current().requestAuthorization( options: authOptions, completionHandler: {_, _ in }) } else { let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) application.registerUserNotificationSettings(settings) } application.registerForRemoteNotifications()
I have added this line to Info.plist:
<key>UIViewControllerBasedStatusBarAppearance</key> <false/>
I've also tried (not working as well):
key>FirebaseAppDelegateProxyEnabled</key> <string>0</string>
I have followed the instructions from https://pub.dev/packages/firebase_messaging and I get notifications when my app is in the foreground (onMessage is executed). However, I get no notifications at all when it's in the background. I've tried everything I could find suggested, nothing works. I am really desperate at this point. It doesn't work for the simulator or the real device. Can this even work? If so, please help me get it to.
-
Kavin-K over 3 yearsI also had same issue few months back, but this article helped me medium.com/@jun.chenying/…
-
ivanacorovic over 3 yearsGreat, I get the notification now! Thank you!!! The fix was to use key>FirebaseAppDelegateProxyEnabled</key> <string>NO</string>
-