FCM Notification for flutter app does not show in iOS system tray

6,020

Solution 1

As per the documentation found on Firebase website regarding apple integration:

For iOS; you must have a physical iOS device to receive messages. Firebase Cloud Messaging integrates with the Apple Push Notification service (APNs), however APNs only works with real devices.

Solution 2

I have had some issues when I didn't ask for the permissions of the notifications in my App. So you should check that you have asked for the permissions of the notifications when executing the App and that it has been acepted because if you don't accept the permissions you could have problems receiving the notifications.

You can add this code in the appDelegate in the iOS project to ask for the permissions when the app executes:

let center = UNUserNotificationCenter.current()
    center.requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
        
        // Enable or disable features based on the authorization.
    }

Or you can also use a package in the pub.dev that can check and request the permissions in your App.

You can also check on the phone if the notifications are enabled for your App.

Share:
6,020
Scorb
Author by

Scorb

Updated on December 27, 2022

Comments

  • Scorb
    Scorb over 1 year

    I have a flutter app where I use Firebase Cloud Messaging for notifications.

    I am sending test notifications via firebase console.

    Notifications function as expected on android.

    On ios the notifications arrive as expected when the app is in the foreground. When the app is minimized in the background, notifications do not show in the system tray. Also no badge shows either even though a badge is set in firebase notification when I send by console.

    Essentially there is no sign a notification has arrived at all until the app is opened again.

    I have followed the instructions found on this page and confirmed I followed the ios integration steps to a T.

    I am testing on a simulator.

  • Scorb
    Scorb about 3 years
    Weird that the notifications arrive when the app is in the foreground though.
  • Antonin GAVREL
    Antonin GAVREL about 3 years
    It is possible that the Firebase team is working gradually to make it work on Simulator as it is quite a huge issue: I have seen countless messages of programmers encountering this problem and encountered it myself (had to borrow iphone from a friend since I don't have one).
  • Zubeir
    Zubeir almost 3 years
    What about this here ? Would this work with FCM? stackoverflow.com/a/60085404/9194653