16th May 2013

Today I was freaking out, I just started this app and it required the ability to track geolocations, obviously this would need to work in the background if the user got a call, or wanted to do another task on their phone. I searched the web and saw many responses saying it wasn’t possible, but it is!

If you’re using the javascript navigator.geolocation.watchPosition the following worked for me using the latest version of PhoneGap at the time of writing (2.7.0).

Go to the “Resources” folder in your XCode project, click on the file that is called “yourprojectname-Info.plist” (this file may be located elsewhere in other versions of PhoneGap). Click the plus next to “Information Property List”. Type in the new field “Required background modes”, click the arrow located next to the new row and in the value for “Item 0″ type “App registers for location updates”.

That’s correct. It works perfectly most of the time. The only thing I’ve found is if you are stationary for 10 minutes or so it will stop making calls. I’m going to test ways of re-initiating it but haven’t done so yet.

I haven’t been able to get this to work. I did as you mentioned, yet when I press the home button in the simulator, it no longer writes to console until I bring the app back up. Suggestions? I’m using PhoneGap 2.6.0 and iOS 6.