Battery optimiszition is blocking the notifications for Android version 8 and above

Hi All, it’s been a serious problem. I don’t know how the other developers over there implementing the push notifications on China based phones with Android version 8 and above.

I’m using cordova-fcm-plugin to implement push notifications on the client side and FCM on the server side to trigger the notifications. Everything was working fine till Android version 7. For Android version 8 and above, in few China phones like One Plus, Oppo, Xiomi etc they have introduced a feature called Battery Optimization. By default all the the apps installed are battery optimized.

Because of this, if the app is killed by swiping from the app tray. Then app will not receive any push notifications. But popular apps like WhatsApp, Gmail, Skype etc are white labeled by Mobile manufacturers, so they will continue to receive notifications even when app is killed.

If I go to settings -> Batter -> Battery Optimization and select the app and chose not to optimize then notifications will be received even when app is killed. But I cannot ask users to do this. I want a programmatic solution to this.

Please let me know, how can I achieve this ? I’m highly curios how come not much of questions related to this on Ionic forum or Stackoverflow.

Note: I have tried cordova-plugin-doze-Optimize already, but no change.