My app tracks location while in background... the location background mode is enabled and i use
[self.locationManager startUpdatingLocation];
This works great on iOS7-8
but it stopped working on iOS9
In simulator it works, but on real device i get no callback while in background... when running the same code on iOS8 device i get normal callbacks as before
Is this documented? Why does it work in simulator and not in device? is it a bug?
When using startSignificantChangeUpdates
it works on iOS9, i wonder if this is some kind of battery saving feature, that they possibly prohibited startUpdatingLocation
You can control what location information your phone can use. Open your phone's Settings app. Under "Personal," tap Location access. At the top of the screen, turn Access to my location on or off.
In the foreground: The app can use your location only when the app is open on your screen or when you ask the app to do something. In the background: The app can use location info at any time, even if you aren't using it.
Background location use. If you give an app permission to access your location while it's in use, the app can then ask to know where you are at all times.
The answer is yes, it's possible to track mobile phones even if location services are turned off. Turning off the location service on your phone can help conceal your location. This is important if you don't want third parties knowing where you are or being able to track your movement.
Use:
if ([self.locationManager respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)]) { [self.locationManager setAllowsBackgroundLocationUpdates:YES]; }
to avoid using a macro that evaluates the system version. This will call setAllowsBackgroundLocationUpdates: on iOS 9 but not on iOS 8.
Please use below reference for location in ios 9
allowsBackgroundLocationUpdates in CLLocationManager in iOS9
This new property is explained in the WWDC session "What's New in Core Location".
The default value is NO if you link against iOS 9.
If your app uses location in the background (without showing the blue status bar) you have to set allowsBackgroundLocationUpdates to YES in addition to setting the background mode capability in Info.plist. Otherwise location updates are only delivered in foreground. The advantage is that you can now have location managers with background location updates and other location managers with only foreground location updates in the same app. You can also reset the value to NO to change the behavior.
The documentation is pretty clear about it:
By default, this is NO for applications linked against iOS 9.0 or later, regardless of minimum deployment target.
With UIBackgroundModes set to include "location" in Info.plist, you must also set this property to YES at runtime whenever calling -startUpdatingLocation with the intent to continue in the background.
Setting this property to YES when UIBackgroundModes does not include "location" is a fatal error.
Resetting this property to NO is equivalent to omitting "location" from the UIBackgroundModes value. Access to location is still permitted whenever the application is running (ie not suspended), and has sufficient authorization (ie it has WhenInUse authorization and is in use, or it has Always authorization). However, the app will still be subject to the usual task suspension rules.
See -requestWhenInUseAuthorization and -requestAlwaysAuthorization for more details on possible authorization values.
Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With