Skip to content

Project configuration

zioolek edited this page Dec 11, 2017 · 3 revisions

Project configuration

Location authorization in iOS 8 - 10

Since iOS 8.0 it is required to add an entry to the Info.plist file that indicates wich location authorization is required by your app:

  • To use the "Always" mode, which the SDK is primarily designed to work with, add the NSLocationAlwaysUsageDescription key. This mode allows your app to be awaken when near beacons (via beacon region monitoring) and to receive detailled beacon data updates (via beacon ranging) for a few minutes while the app is in background. There is no restriction applying when the app in foreground.

  • If you decide to use the "When In Use" mode then add the NSLocationWhenInUseUsageDescription key. With this mode your app cannot be awaken when near beacons and cannot receive detailed beacon data updates when in background. Your app will only get detailed beacon data updates (beacon ranging) while in foreground.

Support both modes (optional)

You can decide to support both modes by providing the two keys. In this case the Ubudu SDK will by default try to get the "Always" location authorization but your users will have the possibility to "downgrade" the app location authorization to "When In Use" from the device settings.

If you'd rather have the SDK require "When In Use" authorization first (and let your user the possibility to "upgrade" the authorization to "Always" later) set the following option on the SDK to YES /!\ before calling start /!\.

[UbuduSDK sharedInstance].requestWhenInUseAuthorization = YES;
Support only "When In Use" mode (optional)

If you decide to support exclusively the "When In Use" mode then add only the NSLocationWhenInUseUsageDescription key to your Info.plist file AND set the same option as above to YES so the SDK will ask for the correct authorization.

[UbuduSDK sharedInstance].requestWhenInUseAuthorization = YES;

Location authorization in iOS 11

If you want to support only "When In Use" mode - nothing changes. However, NSLocationWhenInUseUsageDescription key should be added in all cases. Always mode need additional NSLocationAlwaysAndWhenInUseUsageDescription key.

Warning: asking for "Always" access without providing NSLocationWhenInUseUsageDescription will not work. In that case you might see the following log in your console:

This app has attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain both NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription keys with string values explaining to the user how the app uses this data

NSLocationAlwaysUsageDescription key is now needed only for a backward compatibility. It is not needed for iOS 11.

Remarks
The value(s) for the key(s) can be left empty, but if provided will be displayed in the alert
asking the user if he'd like to grant access to his physical location to the app.
You should provide a description of one or two line(s) of why you need to access your user's location so he will be more enclined to accept.
Warning: if you fail to properly provide the required key then the location access alert 
won't be displayed and your app will never get access to the location of the user.