Raz Buchnik
Raz Buchnik

Reputation: 8411

HTTP request stops due to background throttling when the app is on background

I am using the cordova background geolocation plugin in order to dispatch position when app is on the background. It seems that the plugins functions properly but it fails when the app is more than 3-5 minutes on background to deliver the GPS data using HTTP requests.

Note I am not using the plugin's HTTP request, but Axios (just another HTTP request implementation for react).

In the first 4-5 minutes everything works and HTTP requests are getting send. But after that nothing is happens - no HTTP request are getting send.

Probably the OS shuts this down. I am using Galaxy S7 Android device for these tests. Not tested on something else.

Should I use socket.io for this kind of task or keep using HTTP request but with some fix?

Upvotes: 2

Views: 210

Answers (1)

Jeremy
Jeremy

Reputation: 565

If you are targeting Android 26+ the system places restrictions on background processing. You will need to use a foreground service and show an appropriate notification.

Upvotes: 1

Related Questions