Background service in ionic

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

2 Likes

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.

1 Like

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

is this plugin send data even after app is killed ???

Transistorsoft’s Background Fetch is probably what you are looking for as far as sending data. They also have a great background geolocation plugin. That plugin was forked and is the one mentioned above.

Who said that whatsapp load message after open the app? I see whatsapp has services and sometime notification (checking message) has appear when connection refine. And whatsapp never late to load message, when notification comes, the message is already there.
If you ever use windows phone, then i believe that the way whatsapp do was using push notif, then load message when user open app, because almost every time that i open app, the message has not come yet.