Using navigator.geolocation.watchPosition when iOS app is in background

1,281 views
Skip to first unread message

Szymon Nowak

unread,
Oct 30, 2012, 10:17:44 AM10/30/12
to phon...@googlegroups.com
Hi,

I'm developing an app that requires location service to work all the time (or at least as much as possible). Apple docs state that:

Support for some types of background execution must be declared in advance by the app that uses them. An app declares support for a service using its Info.plist file. Add the UIBackgroundModes key to your Info.plist file and set its value to an array containing one or more of the following strings:

    • location—The app keeps users informed of their location, even while it is running in the background.
Where exactly should I add UIBackgroundModes key, as I don't have Info.plist file in project generated by Cordova (2.2.0 rc2)? It's only in the built version of Cordova app. I added it to myapp.plist, but it my app stopped getting GPS info when I put it in the background. Do I have to change anything in the code or should geolocation.watchPosition just work in the background as well?

Szymon Nowak

unread,
Oct 30, 2012, 10:39:04 AM10/30/12
to phon...@googlegroups.com
Uh... Got it.

In Xcode select yourapp-Info.plist file in Resources folder. Click + on the root element (Information Property List). Select "Required background modes" and as the value of the first item select "App registers for location updated" or just type "location". That's all.

Szymon Nowak

unread,
Dec 3, 2012, 1:22:16 AM12/3/12
to phon...@googlegroups.com
On 2 December 2012 22:12, Konrad Zawadka <konrad...@gmail.com> wrote:
> No problems with longer tracks e.g. 10+ min?

I've tested it just twice so far, each time for about 30min, using
iPhone 3GS with iOS 6.01 and it worked fine.

erik404

unread,
Jan 15, 2013, 6:18:03 AM1/15/13
to phon...@googlegroups.com
Hi Szymon, can you maybe share your solution/code? I am trying the same. Building a PhoneGap solution which runs in the background and updates our database with the current geolocation of the device.

Any help would be apreciated because I am pulling my hair out here....

Op maandag 3 december 2012 07:22:16 UTC+1 schreef Szymon Nowak het volgende:

Ruan Botha

unread,
Sep 30, 2013, 5:40:28 PM9/30/13
to phon...@googlegroups.com
Hi Szymon,

Just wanted to hear if there is any update for this and if it would work for an Android based phonegap app, that is minimized and running in the background?

Thanks :D
Reply all
Reply to author
Forward
0 new messages