Prevent app to be killed from background

Hi,
I am working on an app which uses cordova-plugin-geolocation service to track live location of logged in users. It works fine if app is in foreground. But when we minimize the app, it stops tracking after specific time(5 minutes or something). To resolve this problem , I change battery sever mode to “No restrictions” manually in phone.
So I am facing two major issues here -

  1. I can not change settings manually in each user’s phone. So please suggest if there is any way in ionic 4 to do this through code.
  2. When I change setting manually the app works fine, but android automatically kill the app during phone call or any kind of notification.
    Please suggest me how can I fix the above problems .
    Thanks in advance.

As a user, it would annoy me to no end if an app was able to override my choices about how I want to allocate scarce power resources.

Thanks for your reply.
I completely agree with you, but this app is for one of my client who wants to track location of his employees in working hours. So we can do this type of code change which prevents app to be removed from background.

I guess what I’m trying to say is that perhaps you can use the explanation of “that would cause an arms race that would alienate users” to explain why that sort of thing is prohibited by the OS, because I would be extremely surprised to learn that this was possible at all.

Unless your client is willing to go down the road of jailbreaking all the devices the app is to run on, that is.