since watchposition doesn't run for more than 30 min in background, i have to create a geolocation plugin in order to register position every 5 minute on my webserver. Ther problem is that i don't know quite nothing about objective-c. So anyone can help me or give me some parts of code with i can do something? thanks in advance
1 Answers
You don’t need to create a plugin for your phonegap app to receive location updates in the background. I’ve produced an iOS version of my phonegap-based navigator app and successfully got it receiving position updates while running in the background. I’ve tested it extensively in the “real-world” and it works reliably without any limit on the duration for receiving location updates.
Firstly, you need to be using XCode to develop your phonegap app - I’m not sure you can set the correct properties in your iOS app if you’re using Phonegap Build. You can set the “UIBackgroundModes” key with a value of “location”, which will cause iOS to trigger the JS callback function you have registered with watchPosition() each time a location update is received.
See this page for details about iOS project keys.
See this page for how to set the background modes key in XCode. The value you want to select is “App registers for location updates”.
Hope this helps!

- 30,083
- 11
- 93
- 155
-
In my testing, after setting "App registers for location updates", my app will only receive location updates for about ten to fifteen minutes while standing still. Then the updates stop and do not resume. Is this different in your testing? If so, is there something else you're doing? "App registers for location updates" does not seem sufficient on its own. – Scott Saunders Aug 15 '13 at 15:22
-
@ScottSaunders do you find any solutions to this? – Stack User 5674 Sep 03 '13 at 05:12
-
@Ajmal: No, I did not. There are some new things you in native code (http://stackoverflow.com/questions/17484352/iphone-gps-in-background-never-resumes-after-pause), but I have not explored whether they can be integrated into PhoneGap. – Scott Saunders Sep 03 '13 at 13:30
-
@ScottSaunders Sorry for delay in replying. I didn't encounter this problem when field testing my app as it's a guided walk app, where the user is constantly moving. I think it's the "standing still" scenario that makes the difference, because today I tried leaving my app running and the device standing still and my app also stopped receiving position updates after about 10 minutes. I then tried leaving my app running again while walking around for over an hour and it continued to receive updates for the entire time. – DaveAlden Sep 03 '13 at 18:55