pushy / pushy-flutter

The official Pushy SDK for Flutter apps.
Apache License 2.0
21 stars 19 forks source link

Notification is not received when the android app is killed #42

Closed santhosh-mobile-engineer closed 2 years ago

santhosh-mobile-engineer commented 2 years ago

This is a very common scenario. Most of the apps like what's app , Skype , LinkedIn and all receiving notification when app is closed .

And notification doesn't rely on app being open or close .

But when it comes to pushy notification doesn't arrive when app is closed . Is there anything we can do to receive notification when app is killed ?

pushy commented 2 years ago

HI @santhosh-mobile-engineer, Thanks for reaching out. We'd be glad to assist.

1) What is the device manufacturer name and model you are experiencing this issue on? 2) Are most of your end users located in mainland China and using Chinese manufacturer devices?

Some Chinese Android manufacturers make use of custom power-saving restrictions that inhibit sending push notifications to your users while your app is in the background, swiped away from recent apps, or after a device restart.

Popular apps such as Skype, Facebook, LinkedIn, Facebook Messenger, WhatsApp, and more are whitelisted by default from these power optimizations by the Chinese OEM manufacturers. These OEMs want users to have a great notification experience on popular apps, while sacrificing user experience on non-popular apps in exchange for longer battery life.

Most notably, Chinese market devices from the following manufacturers include custom power-saving restrictions:

In order to receive notifications in the background on these devices, there are two options:

a) If the affected users are not within mainland China, we recommend implementing FCM high priority fallback delivery. This is proven to work around several of these manufacturers' custom power saving mechanisms (Xiaomi, OnePlus, and more), by having Pushy deliver your notifications through MQTT and Firebase Cloud Messaging's high-priority channel simultaneously, while only waking up your app once.

b) If the affected users are located within mainland China, consider displaying a custom dialog asking those users to whitelist your app from the respective manufacturer's power saving mechanism(s), within the device settings. Unfortunately, the steps for achieving this are different for each manufacturer, but are closely documented on DontKillMyApp. Users using these phones are aware that by default all non-popular apps are killed when swiped away / in background, and have most likely already added a few apps to the battery optimization whitelist.

We apologize for the lack of an easy, straightforward solution -- there is no easy workaround for this, except for having your users actually whitelisting your app. Our SDK includes a few built-in mechanisms to attempt to keep the connection active specifically on Chinese devices, but these mechanisms may sometimes still be throttled by the OS.

Please let us know if you have any questions as per the above and if anything is unclear.

santhosh-mobile-engineer commented 2 years ago

Thanks for reverting back . We will try this and let you know

pushy commented 2 years ago

Hi @santhosh-mobile-engineer, Sounds good. Please let us know if it ended up working, and if you still need assistance with this issue.