Ashutosh Sharma
Ashutosh Sharma

Reputation: 1549

Flutter FCM is not working when app is closed

I have been trying to make an app in Flutter that receives a push notification. When I run it on Redmi note 5 I get the notification when the app is in foreground or background but I don't get any notification when the app is terminated. On the other hand, When I run it on OnePlus 6T everything works even when the app is terminated. I think the problem here is that the app is not allowed to run in background or something but how do instagram, facebook... achieve this?

Upvotes: 6

Views: 6213

Answers (4)

For those who are facing a similar problem with any device, check if the device is listed here: https://dontkillmyapp.com/

The problem is, some android manufacturers customize the system with features for battery savings that just kill our app, and prevent it from working and receiving notifications in background. Some giant apps like facebook, uber, instagram work just fine because they're usually listed in a 'whitelist'.

There isn't much we as developers can do in such scenarios, but usually there is an option on the system to allow a specific app on background. The previous link clarify these use cases.

Upvotes: 2

xkxeeshankhan
xkxeeshankhan

Reputation: 431

In my case I added two app into the same Firebase project so the google-services.json get changed also for the first app, so downloading the new json file and replace it with the old one works for me.

Upvotes: 0

Ashutosh Sharma
Ashutosh Sharma

Reputation: 1549

I solved it. Basically, all I had to do was go to the app settings and in there I turned on autostart in permission and it worked like magic.

Upvotes: 0

Saeiddjawadi
Saeiddjawadi

Reputation: 332

First of all, check the permission in manifest file then on your App startup, ask users to grant permissions.

Look at this Link

Upvotes: 0

Related Questions