skip to Main Content

I have problems with FirebaseMessaging package for push notifications. The onMessage event is not triggered

Well, what the title says. When I send notifications using the Firebase tools (firebase console or API) I receive notifications and the callbacks are triggered, but when the notification is sent using APNs, it shows the notification (if I set the setForegroundNotificationPresentationOptions) but the onMessage isn’t triggered.

For this app, I need full control of notifications, so I need to receive the data on onMessage first, then check if I want to show it or not, if I want to save it or not, and other conditions.

This works for Android, but for iOS it doesn’t.

Does firebase_messaging work for this case? What can I do to listen when a notification is received via APNs?

Note: I’m testing it on a real device and I have the APNs key on firebase (I mean, if I set setForegroundNotificationPresentationOptions and it shows the notification, I think the configuration is right).

2

Answers


  1. Chosen as BEST ANSWER

    Shortly, here is the answer

    [https://github.com/firebase/flutterfire/issues/4300#issuecomment-916883580][1]

    I did a fork to the package, added it to my project's package folder, and made that condition always true.


  2. I solved the above problem, sending the below APNS push notification payload;

    {
      "APNS_SANDBOX": "{"default":"Test","data":{"jobType":"DeviceEventCheck"},"gcm.message_id":"123456","priority":"high","aps":{"alert":{"title":"Title","body":"Body"},"badge":1,"sound":"default"}}"
    }
    

    above solution work form me

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search