Search code examples
firebaseflutterfirebase-cloud-messaging

Firebase messaging background handler not called when app is terminated (Flutter)


I am trying to update my app's badge count number of my flutter app when receiving push notifications when the app is terminated.

The Firebase messaging background handler works fine if the app is in the background but doesn't work when the app is terminated.

I have read in the documentation :

On iOS, if the user swipes away the application from app Switcher, it must be manually reopened again for background messages to start working again.

Does it mean that on iOS there is no way to update the badge count using the firebase background handler (by the logic you implement in the handler of course, just need the handler to be called) ?

Any app do this today so i wonder why it would not be possible with Firebase Messaging.


Solution

  • I have actually found a solution, by using a service extension in swift and passing data as payload server side, using content-available: true in python.

    Here is the documentation i have followed to implement the notification server side.

    Also, there is an ongoing bug / feature request for flutter and Firebase regarding this case.