Xiaomi does not receive notification when application is not running
Solution 1
There are five settings that needs to be done manually in case of xiaomi to properly run any application. I have done a lot of research on this and there's no way to fix these settings programmatically. These are the settings:
- Auto Start -> ON (Toggle and restart your app)
- MIUI Optimization under Developer Options -> OFF
- Memory Optimization under Developer Options -> LOW/OFF
- No restrictions on background activities under Battery & Performance Settings
- Battery Saver -> OFF
There are many other devices in which the manual settings needs to be done in order for the app to work as expected e.g. Lenovo, some Micromax devices. Companies impose these kind on restrictions on background activities to improve the overall battery life. Some apps like facebook and whatsapp work correctly as these might have been included as system apps.
Solution 2
After MIUI 6 & 7:
MIUI power saving mode is default set to "Standard" (Background access to the location services and the network will be restricted)
Where to set:
Settings -> Additional settings -> Battery & performance -> Manage apps battery usage -> Power Saving Modes -> Set to Off (MIUI won't restrict background activities)
Solution 3
As for my understanding once you clear apps or clear memory in Recent Apps menu, xiaomi (or MIUI rom) will force close all the services and memory related to that app similar to user going to settings and force stopping app ,
This Link talks about the same issue, hence all the Broadcast receivers and Services will be ended unless started by the user again, so the notification wont be received,
However you can try just enabling auto-start for your app permissions in settings and If it still doesn't work try creating service that restarts by itself and enable auto-start in the settings, AutoStart is very important in MIUI, untill its enabled all the notification or app activity will be force closed and will never start
N Sharma
I have done masters in Advanced Software Engineering. I have worked on various technologies like Java, Android, Design patterns. My research area during my masters is revolving around the Recommendation algorithms that E-commerce websites are using in order to recommend the products to their customers on the basis of their preferences.
Updated on February 01, 2020Comments
-
N Sharma about 4 years
I am working on an application where I am using Google Push Notification. Application receives notification when it is running in Xiaomi phone otherwise when it's killed it does not receive notification.
If we want to receive notification if application is killed then we need to allow auto restart app manually from security app of xiaomi. I want any trick to do this programmatically without asking user. Is there any way to do this ?
-
Manikanta over 8 yearsHow to create a service that restarts by itself?
-
Ujju over 8 yearsYou can do It by many ways , first try the START_STICKY ,so it tries to recreate service if its ended by system, or Just listen to onDestroy of service and try to start again
-
Sudhanshu Gaur almost 8 yearsOther apps like Facebook, whatsapp etc, they send notifications even when my app is not in ROM so can you please tell me how these apps solve this issue in MI phones.
-
Ujju almost 8 years@SudhanshuGaur No, it wont run any background services if its not enabled in 'Autostart', by default all the newly installed apps are in disabled mode, However few popular apps like FB and WhatsApp are Enabled by dafault when you install , but you can still disable them manualy and test fr urself, they wont receive any more messages
-
Sudhanshu Gaur almost 8 yearsYea i already know that, i wanted to ask what code does FB or Whatsapp have wrote so that their apps are installed by default with 'autostart' option.
-
Ujju over 7 years@SudhanshuGaur Either that or ROM has already whitelisted some very common apps by itself without FB needing to write any code, Since MIUI does not provide any SDK of its own to control its custom settings I would go with latter
-
Haroon over 7 yearsAny Update on this ?
-
Bhavin Patel almost 7 yearsAny one found solution?
-
Bhavin Patel almost 7 yearsHow to find in which phone need to do auto-start code? Means I know In MI device it is required for auto-start But don't know about others .
-
Rodney almost 7 yearsHow does this work on Hybrid apps - e.g. with Cordova?\
-
Allan Nienhuis over 6 years@Rodney you could try writing a native cordova plugin? just an idea.
-
Saul_programa almost 6 yearsthanks, i just tested on my xiaomi with MIUI global 9.1 and now my Intent Services works!