With iOS 8, Apple introduced changes to it's Location Services authorization model. Those changes affect every app using iBeacon. Beacon-enabled apps no longer require the Background App Refresh, but they need to ask for one of the permission types to access location data.
Location Services permissions:
- always authorization - the app can access location data when it's visible on the screen, but is also given access to a certain subset of these when in the background or even when terminated
- when in use authorization - the app can access location data only when it's visible on the screen
- denied - the app can't access location data at all
How does it affect Ranging and Monitoring?
With always authorization, you can use Ranging in the foreground and region Monitoring when in the foreground and background. Even if your app is killed while monitoring, it'll still be relaunched by iOS to handle incoming monitoring events.
With when in use authorization, you can use Ranging in the foreground, but you won't be able to start Monitoring at all - not even in the foreground!
When denied access to Location Services, your app won't be able to range or monitor for beacons.
What does all of this mean for my app?
In order to use Ranging and Monitoring, you need to obtain appropriate permission to access Location Services - when in use for Ranging and always for Monitoring.
- Add a mandatory description of how your app uses Location Services
You can do that by navigating to your Info.plist file in the Project Navigator (it's in the Supporting Files directory), right-clicking on it and selecting Open As - Source Code, and adding the following code just before the </dict> line:
For when in use authorization:
<string>This application uses your location to determine which table you're at when ordering your coffee.</string>
For always authorization:
<string>This application monitors your location to show you promotional offers in shops you're passing by.</string>
- Request appropriate permission
Before you start using beacon ranging or monitoring, you're required to call one of the following
If your application is doing this for the first time, the user will see a pop-up notification asking them to allow the app to access their location. This pop-up will contain the UsageDescription you provided in the Info.plist file.
Once the user grants or denies the permission, subsequent calls to requestWhenInUseAuthorization or requestAlwaysAuthorization will not present any more pop-ups. To change the permission, direct your users to the Settings app. Note that it is still mandatory to call either requestWhenInUseAuthorization or requestAlwaysAuthorization before starting Ranging or Monitoring - even if your app was already granted the permission and no pop-up is going to be displayed!
- Determine if your app has been granted the requested permission
If your app does not have the appropriate permission to use Ranging or Monitoring, no error will be reported - your ESTBeaconManagerDelegate will simply not be getting any location updates, such as didRangeBeaconsInRegion or didEnterRegion.
It’s a good practice to make sure your app was granted necessary permission to use Location Services and modify its behavior if the user chose to deny such access.
You can monitor the authorization status in two ways:
- By calling the ESTBeaconManager's authorizationStatus class method and checking the CLAuthorizationStatus value returned.
- By implementing the beaconManager:didChangeAuthorizationStatus: delegate method and listening for changes in the authorization status.
For more details, feel free to consult Apple's official CoreLocation documentation.
How does this affect Estimote SDK?
Only Core Location-based methods are affected. For a full list of such methods, take a look at our iOS API reference.
None of the above applies to Core Bluetooth-based methods. For example, startEstimoteBeaconsDiscoveryForRegion is a Core Bluetooth-based scan and does not fall under Location Services authorization model. You can use this scan when your app is in the foreground – and in the background, provided you have the Bluetooth-central background mode enabled.