I have a very basic HTML5 page setup for offline use which tells me when it is offline and when it is online.
I've added location tracking to it to record the position of the device while it is running:
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
alert('geolocation not supported');
}
setTimeout(function() { getLocation(); },5000); // calls itself every 5 seconds
}
This seems to work well, however there is a small problem.
On a desktop browser, you can minimize the page and the location keeps being recorded.
On a mobile device (i.e. iOS), when you minimize the browser, it is suspended i.e. the location no longer gets recorded.
Is there a way to force a webpage to be 'kept alive' on mobile devices? I know there's a similar feature for apps where you can go back to the homescreen and the app keeps running.
As you can see, this is not a "session being lost" issue, it is simply that all scripts on the page are stopped while the web page is not being viewed.