1

Is it possible to take gps on when phonegap (iOS) app is in background?? In my app gps go off after some seconds. I use phonegap 3.1, backbonejs, requirejs, jquerymobile...

Some plugins???

thank's!

Flavio Bontà
  • 164
  • 1
  • 13

1 Answers1

1

To keep your app running in the background on iOS, you need to build it using Xcode in order to set a project property which will allow your app to receive location updates while in the background. As far as I know, Phonegap Build does not allow you to do this and does not do it for you.

You can either manually edit the project .plist and add the key “UIBackgroundModes” key with a value of “location” or, with your project open in XCode, add the "Required Background Modes" key with a value of "App registers for location updates". This will cause iOS to trigger the JS callback function you have registered with navigator.geolocation.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”.

DaveAlden
  • 30,083
  • 11
  • 93
  • 155
  • Note that if the user stays still for 10 mins or more while your app is running in the background, iOS will stop passing location updates to it. AFAIK, there's no way to stop it doing this. See [this question and answers](http://stackoverflow.com/questions/17484352/iphone-gps-in-background-never-resumes-after-pause) for details. However, once the app is brought to the foreground, it will receive location updates again. – DaveAlden Oct 25 '13 at 16:29
  • my application is about a navigator, I think that keep active. [See this](http://stackoverflow.com/questions/9738488/run-app-for-more-than-10-minutes-in-background) – Flavio Bontà Oct 28 '13 at 14:39
  • Yes, you're app should be fine then. My apps are also navigator apps for self-guided walks and I've never had this problem because my users are always moving :-) – DaveAlden Oct 28 '13 at 15:02
  • Dave do you know if this still happens? And also, does iOS start sending updates again if you start moving again? – sdrubish Sep 06 '15 at 12:20