
19 Answers, 1 is accepted




About your last post - Jan-Dirk is right, you do not have provision for this App ID, for more information refer to:
- Register an App ID
- Create a Certificate for Development
- Create and Install Certificate and Provisioning Profile for iOS Development
If you have deployed it on your iOS device with development provision and continue to have problems, can you share what is your device and iOS version, so we can test locally?
Regards,
Steve
Telerik
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.

Any suggestions on how I can automatically check if it is on and restart it if not (while in the background)? Since I really only need it to check every 10 or 15 seconds, I tried putting a javascript timer and then calling geolocation.getCurrentPosition instead of the geolocation.watchPosition but it appears (not fully confirmed), that the javascript timer goes to sleep in the background so this is of no use. I also tried setting the frequency and maximumAge but it seems to ignore the setting and still updates every 1 second.
iOS Location Services use information from cellular, Wi-Fi, and Global Positioning System (GPS) networks to determine your approximate location. Based on that, your app should not have access to any of those in order to stop reporting position. This does not mean the location service is not running, it means it cannot determine whether your position has changed and that is why it does not report anything, as by default it only reports position when significant changes in position occur.
Also bear in mind the following paragraph from Apple's documentation:
The inclusion of this value in the
UIBackgroundModes
key does not preclude the system from suspending the app, but it does tell the system that it should wake up the app whenever there is new location data to deliver. Thus, this key effectively lets the app run in the background to process location updates whenever they occur.The only background service that is never suspended is voip.
Regards,
Steve
Telerik
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.



Or is the right question how do I keep the location icon on all of the time?
Steve, is it possible that you can load your sample app onto your iPhone, start the Geolocation watch and then minimize it and check again in an hour or so to see if the location icon goes off?
I completely agree that asking gets us forward and there is nothing wrong in your question. The thing is we do not add anything to this process, we simply include the necessary
UIBackgroundModes
for your app into the info.plist file as required by Apple and from there on, it is their show. My point in the previous post was that real testing of the location background mode would include you moving with your iOS device so that it detects significant changes in location. If I read Apple documentation right, if your device just sits on your desk, there are no location changes and it would be suspended after some amount of time. If you believe there is a problem with this service, I would suggest contacting the guys at Apple or Cordova for an expert view on this.Regards,
Steve
Telerik
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.

So based on what you have said, is there something I can do to keep a constant poll going so to keep the location service active?
We appreciate the context of your app and understand your concerns. To answer your question directly, no you do not have any additional control over apple's location background mode. I would suggest reviewing the following articles on apple's site that elaborate on it:
if it does not work as you would expect, then you might consider using the significant-change location service instead (which by the way is recommended by Apple whenever you do not need high-precision location data):
Regards,
Steve
Telerik
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.

Let me try shedding some light on iOS location services. -[CLLocationManager startMonitoringSignificantLocationChanges] isn't implemented in the Cordova APIs. There's a plugin that exposes the API to JavaScript, but it's not Cordova Plugman-compatible and so you can't use it in Icenium without some rewrite of the plugin itself.
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.
Regards,
Yavor Georgiev
Telerik
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.

Yavor, Excellent post, thank you!
You stated one thing that gives me hope in resolving my issue: 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.
Correct me if I'm wrong, but I assume from this then that the when the GPS sensor goes off, the navigator.geolocation stops watching. So I guess the right question is how can I do a timer and poll the GPS every minute instead? Will a regular JavaScript setInterval loop stay active in background mode or is there a better way to setup a timer to do something on a regular basis?
When the app is suspended, any watches created by navigator.geolocation.startWatch are preserved. Whenever iOS decides to resume your app and activate the GPS sensor, it'll call -[CLLocationManagerDelegate locationManager:didUpdateLocations:] which Cordova's native geolocation code on iOS implements. Cordova's CDVLocation class on iOS (which is exposed as navigator.geolocation in JS) keeps a list of all the watches created by startWatch and whenever iOS calls the locationsChanged callback, even when resuming the app in the background, all the watches will be signaled. In essence, navigator.geolocation.startWatch survives backgrounding and GPS availability, except in cases where the error callback is called. Once the error callback of a watch is invoked, the watch is considered broken, geolocation stops, and the app should call startWatch again or fail gracefully. By the way, is it possible that the error callback on your watches is invoked?
Even if you could periodically execute a function while in the background (and iOS doesn't do this, neither in JavaScript, nor in Objective-C. Only voip apps are guaranteed to be active in the background all the time), subsequent calls to navigator.geolocation.startWatch won't force turning on the GPS sensor if it's on standby because of the way Cordova's CDVLocation and Apple's CLLocationManager.
Regards,
Yavor Georgiev
Telerik
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.

At this stage, it is possible to get location updates even when the app is running in the background on an iOS device.
This could be achieved, with the Location updates Xcode background mode. More information about this is available in the iOS Background Execution article.
Regards,
Preslav
Telerik by Progress
Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.