Background service in ionic


#21

I am trying one thing for my location tracking app .

Install background-mode plugin
Check Docs :https://ionicframework.com/docs/native/background-mode/
put app.componenet.ts file controller >

this.backgroundMode.excludeFromTaskList();

This function protect the app from killing


#22

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.


#23

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.


#24

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


#25

Didn’t know of this plugin.

Interesting. Thanks


#26

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 ???