Background service in ionic


I am trying one thing for my location tracking app .

Install background-mode plugin
Check Docs :
put app.componenet.ts file controller >


This function protect the app from killing


That’s just ignorant, to assume battery will be consumed because a process is running. You’re making so many assumptions.

A classic approach will be to have a spin-wait model that incorporates a long sleep. So that you’re polling once a minute, once an hour, or even once a day. And each period of activity could be strictly constrained, e.g. poll a folder, etc. Some activities would not even require WiFi/cellular, or activating display. So why would you think there would be a discernible battery drain?

Your main reason is likely because you honestly don’t know how to do this properly.


That’s a fair criticism.

The primary assumption I’m making, which is based off an admittedly cursory reading of cordova-background-plugin issues, is that while device OS makers have put a great deal of thought into resource management and process scheduling, Cordova (and therefore Ionic, modulo future developments wrt Capacitor) is not in a good position to take advantage of them.

I’m certainly open to evidence to the contrary.


hello, can you please say how you can do this? may be useful for me, thx :slight_smile:


Didn’t know of this plugin.

Interesting. Thanks


phone will be locked through an app and locked until user done something like swipe, or a different pin then the phone original pin etc… how i can do this with ionic ???