I have a small android application project (Used for a local community news app)on android, which is (or was) working on API 22 and onward. Only a issue recently came to our notice is that on Chinese phones like Xiaomi or Oppo or Vivo our notifications (tried both local/Firebase) are not working even when the application is white-listed.
I see some suggestions on online blogs to use AlarmManager (but I guess this is bad idea - for real time notifications), not sure
I have also tried trading on code like below, but still no luck
https://github.com/commonsguy/cw-omnibus/tree/v8.4/Notifications/Foreground
What I've figured out is, if the app task is locked, it will be persisted and my app notification work.
See the image below:
How to programmatically achieve this?
Can it be a single code (or module) for all the versions of Xiaomi or Oppo or Vivo (or say MiUI)?
Yes i also faced this problem, i have tried many given solutions in oppo and vivo mobiles but problem still not solved.
did you try onTaskRemoved() method in Service class? when we swipe app or kill the app onTaskremoved() method is called instead of onDestroy() of Service class.
So maybe there is a solution if we send a broadcast receiver in this method which restart the Service.
And also look this thread also:
How to enable auto start for my app in xiaomi programmatically
Maybe it helps.