So I recently had a job that required me to set up Core Location Services for iOS, which I haven’t tinkered with since Apple released iOS 8, and as it turns out they made a few pretty important changes in their implementation.
Unlike previous version, iOS 8 will now require an authentication before start location services. Although this is a pretty simple task, and only necessitates a few extra lines of code, it can slow down online casino your coding quite a bit, particularly if your expecting the Core Locations service to work the same way it did in iOS 7.
There are two steps that need to be done to get Core Location working in iOS 8:
- The first thing that you’ll need to do is to add two lines of code to the instantiation of your Core Location Manager.We show the implementation below:
There are two kinds of authorization that you can request, WhenInUse and Always. WhenInUse authentication will allow the app to receive location updates only when the app is in the foreground. Always authorization will allow the app to receive location updates both when the app is in the foreground and in the background.
You will need Always authorization to use the following location types :
- Significant Location Change
- Boundary Crossing (Geofences)
- Background Location Updates (e.g. Fitness, Navigation apps)
- Visited Locations (iOS 8+)
- Deferred Location Updates
All these location types have the power to wake the app from suspended or terminated when a location event occurs.
- The second thing that you’ll need is add the plist keys for the authorization that you need to add to your app.
Both of these keys take a string which is a description of why you need location services, which will be displayed by the UIAlertView that asks the user to allow your app permission to use the Core Location Services, so phrase it carefully.
You’ll need to include the key for the corresponding services that you’ll choose to implement, but I tend to include both (it can’t hurt after all).