Automating the iPhone HTML5 tracking updates

Auto tracking from a mobile device

Automatically Tracking a Mobile Device with HTML5

Now, if you read the previous post about using HTML5 to geolocate your iphone and show the location on a map you will recall that I said we would automate the process in Part 2. The system we created in part 1 works pretty well but it relies on you actively loading the page on your phone to create the “check in” and update the database with your latest location.
This isn’t so bad and maybe you want to leave it this way so that you only check in as and when you want people to know your location.

For me I prefer solutions that require zero effort on my part and can be 100% automated meaning I don’t have to worry about remembering to update them.
Sadly this only works on Jailbroken iPhones, but jailbreaking is so easy and brings so many benefits that if you don’t have a jailbroken phone you are a plonker.
The way I managed to solve this on my iPhone was to add a little line of JavaScript to the HTML5 page in order to refresh the page and get a new location every 20minutes. Then I simply had to find a way to run the page in the background of my iPhone and it would automatically update the location every 20minutes. Simple.
So first thing’s first, we add a line of JavaScript the the HTML5 Document to auto-refresh every 20mins.
Open up the geolocate.html file and add


Right below the line:

var myDiv1 = document.getElementById("loco").innerHTML="<iframe src='"+lati+"&longi="+longi+"' frameborder='0' width='0' height='0'></iframe>";

The number 1200000 is 20minutes in milliseconds, you can change this number to adjust how often you would like the position to be checked. For example 5000 would be every 5 seconds 3600000 would be every hour.
Next I downloaded a new web browser to use specifically for loading the position location page meaning that I could continue to use the safari browser without upsetting the automation of the location.
For this I chose SkyFire browser for iPhone which is a pretty good iPhone browser.
Now to make the script run in the background we have to download an App from Cydia called Backgrounder.
Simply open up SkyFire, navigate to your HTML5 geolocation file on your server then use the Backgrounder to run the app in the background of your phone.

If you want to retain your WiFi connection even during locked mode you might alway wish to download Insomnia that keeps you WiFi connected.

There really is little else too it. It works but it does drain the battery so maybe de-activate it if you want to save power :)