Can I keep an App running the background in the forever?

Ionic 4: I would like to pull User’s geolocation and send a POST request to the server when the app is in the background, foreground or even when it is terminated.

There is this module, https://ionicframework.com/docs/native/background-geolocation, which does not work. Hence I would like to use Background mode (https://ionicframework.com/docs/native/background-mode) if it works and keep pulling the location in the background after a certain interval.

I’m thinking to use the background mode and use a sleep function in the background to pull the location. I’m afraid the app may get closed by the Android system if it runs too much time in the background. And the sleep function may not be the best way to achieve this.

What is the best way to achieve my intent?


Check this

I really appreciate your effort in Googling, but I need a library which is free.

1 Like

Cool please post your answer if you are able to achieve this.
I might be able to save some $.

1 Like

Sure, will definitely do!

1 Like

Simple Answer: No it isn’t. Forever is a large time-range :smiley: There is currently no free plugin to achieve this (and will never be i think). The Plugin: https://github.com/transistorsoft/cordova-background-geolocation-lt is the best but it must be paid for Android. In our team we purchased it, because it isn’t that expensive, In Combination with a Background Mode Plugin i achieve to run without interruption for many hours.

2 Likes

Hi,
I am ready to pay

I need to push app data to our database for every 20 minutes forever(even app terminates)

Please advice.