Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move an Android App in Auto Start List of Mi Note3, so it receives Push even app is closed

I am working on an android app and from last 2 weeks i am facing a issue in MI Phones that they don't receive Push Notification when application is in Background State or Inactive State. This is working great in other devices like samsung, micromax etc.

At last i solve it by Moving My application in Auto Start Mode through Device Permission Section

Security -> Permission Section -> Auto Start -> MY_APP -> Mark Toggle to On.

When i follow above steps i found that Facebook and whatsapp are already in AutoStart List, means it is possible to move an android application in AutoStart by code.

So can anybody please help me with some piece of code or Tutorials which i can follow to solve this issue.

like image 260
Rajendra Khabiya Avatar asked Jan 21 '26 21:01

Rajendra Khabiya


1 Answers

You can use cordova-plugin-autostart by enabling autostart after boot

cordova.plugins.autoStart.enable();

If enabled is not called, then by default it will be disabled

cordova.plugins.autoStart.disable();

In the config.xml the following needs to be added

<gap:plugin platform="android" name="cordova-plugin-autostart" version="2.0.1" source="npm"/>

NOTE: Installation to the SD card will prevent the automatic start of your app after the boot

like image 157
Sreehari Avatar answered Jan 23 '26 10:01

Sreehari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!