I'm using CoreLocation
framework in my app in Xcode7(pre-released),and I noticed that there is a newly added property called allowsBackgroundLocationUpdates
in CLLocationManager
class.
What's the relationship between this property and the location updates in the Background Modes of the Capabilities tab. What's the default value of it and does it affect apps running in iOS9?
Here is a summary of many methods that are updated from iOS 8 to iOS 9
Many APIs and codes should be searched for each framework you are using. So search in General the framework and then find these methods to update depreciated methods.
Well, I'm still using xCode 6, since 7 beta always crashes with the simulator, and I have this problem although I don't even link against iOS9! And I can't set this property since it doesn't exist in iOS8! Oh Apple, when will the torment end?!
I changed it to this xCode6 compatible version by doing this late bound invocation:
Confirmed working on iOS8 (doesn't do anything) and on iOS9 beta 6 (invokes the method correctly).
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
toYES
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 toNO
to change the behavior.The documentation is pretty clear about it:
If you're using CoreLocation framework in your app in Xcode7(pre-released),and you may notice that there is a newly added property called allowsBackgroundLocationUpdates in CLLocationManager class.
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
toYES
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 toNO
to change the behavior.The documentation is pretty clear about it:
Set Info.plist like:
The syntax for the Info.plist configuration looks like this:
Or pull up the Capabilities tab of your app target.
Use like:
I write a Demo Here (Demo2)
I faced the same location service on background Mode for iOS 9.0.x and I fixed it as recommended in this post by adding below codes
However it doesn't work in iOS 9.1 Does anyone have the same problem??? If so, please kindly help. Thanks