Let me try shedding some light on iOS location services. -[CLLocationManager startMonitoringSignificantLocationChanges] isn't implemented in the Cordova APIs. There's a plugin
There are a couple of differences between startUpdatingLocation (the method used by Cordova on iOS) and startMonitoringSignificantLocationChanges. startUpdatingLocation
keeps the GPS sensor on until stopUpdatingLocation is called. It can report location changes with a degree of accuracy specified by the caller. If you build your app with the location background mode enabled, call navigator.geolocation.startWatch and then switch away from your app, iOS will forcefully set the accuracy on the location manager to the lowest setting. What's more, the system can decide to suspend your app and resume it only to report a location change and then suspend it again a short while after. While your app is in the background, active or not, iOS decides how to manage the GPS sensor and may even turn it off for a while according to their power management rules, and only poll it periodically to check for changes.
On the other hand, an app using startMonitoringSignificantLocationChanges doesn't need the location background mode. This API allows for the app to be killed by the OS, not only suspended. Calling this method tells the OS that it should launch your app in the background whenever it detects a significant change in location, and then kills it again unless the app requests an extension (which can last up to 10 minutes) to do network requests or other IO with the new information. However, the GPS radio doesn't come into play here - rather, the device relies on cell towers and WiFi hotspots to decide if its location has moved significantly. Depending on cell infrastructure, this can provide a wildly varying degree of accuracy. Only when the system wakes your app can it poll the GPS.
All that being said, if you use the background location mode and have called navigator.geolocation.startWatch, your app should be resumed and the startWatch callback invoked once the system detects a significant change in location. Again, depending on circumstance, exactly when this happens can vary. You can try cheating iOS by connecting the device to a car lighter charger - iOS is much more liberal with background services when it's connected to a power source.
However, if that doesn't work out for you, there are a couple of things you can do - you can either experiment with the plugin I linked to in the beginning of my post, or you can try another plugin
that will disable the device's auto-lock, as long as the app is in the foreground. This will make sure your app never goes in the background unless the user presses the Home or Power buttons on the device or otherwise switches away from your app.
The folks on the Apple Developer Forums
and the Cordova forum
might know more about this, so you might want to check those out also.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Missed our first webinar, watch it here.
Share feedback and vote for features on our Feedback Portal.