Overview
Radar requires location permissions to track the user’s location. iOS provides two levels of location authorization:- When In Use - Location access only while the app is in the foreground
- Always - Location access in both foreground and background
Required Info.plist Keys
Before requesting location permissions, you must add usage description strings to your app’sInfo.plist file. These strings explain to users why your app needs location access.
Required Keys
Replace the placeholder text with a clear explanation of why your app needs location access. Be specific about the features that require location.
Optional Keys
If you’re using motion detection features:Background Modes
For background tracking, you must enable thelocation background mode in your app’s capabilities:
Requesting Permissions
iOS 13.4 and Later
On iOS 13.4 and later, you should request foreground permission first, then request background permission if granted:On iOS 13.4 and later, the OS will show the background permission prompt in-app after the user grants foreground permission.
Before iOS 13.4
On iOS 13.0-13.3, request Always authorization directly. The OS will show a foreground prompt in-app, then show a background prompt later at a time determined by the OS.Permission States
TheCLAuthorizationStatus enum defines the possible permission states:
.notDetermined
.notDetermined
The user has not yet been asked for location permission. Call
requestWhenInUseAuthorization() or requestAlwaysAuthorization() to prompt the user..authorizedWhenInUse
.authorizedWhenInUse
.authorizedAlways
.authorizedAlways
.denied
.denied
The user has explicitly denied location permission. You should direct users to Settings to change the permission.
.restricted
.restricted
Location services are restricted, typically due to parental controls or enterprise device management. Your app cannot request permission.
Checking Current Authorization
You can check the current authorization status at any time:Provisional “Allow Once” Permission
Starting with iOS 14, users can choose “Allow Once” which grants temporary permission that expires when the app is backgrounded. If the user selects this option,authorizationStatus will return .authorizedWhenInUse, but permission will need to be re-requested the next time the app is launched.
Best Practices
Explain before requesting
Show an explanation screen or alert before requesting permission. Explain what features require location access and how it benefits the user.
Request at the right time
Don’t request permission on app launch. Wait until the user is about to use a location-dependent feature.
Use clear usage descriptions
Write clear, specific
Info.plist usage descriptions that explain the value to users. Avoid generic text.Good: “We use your location to show nearby restaurants and provide delivery tracking.”Bad: “This app requires location access to function.”Handle permission changes
Implement
locationManagerDidChangeAuthorization to handle when users change permissions in Settings.Gracefully handle denial
If permission is denied, degrade gracefully and provide an option to open Settings.
Radar Status Codes
When calling Radar SDK methods, you may receive permission-related status codes:Testing Permissions
When testing, you can reset permissions for your app:- Open the Settings app
- Go to Privacy & Security > Location Services
- Find your app and change the permission
- Or use the Simulator: Features > Location > Custom Location
Common Issues
Background permission not working
Background permission not working
Make sure you have:
- Added
NSLocationAlwaysAndWhenInUseUsageDescriptiontoInfo.plist - Enabled the
locationbackground mode - Called
requestAlwaysAuthorization()after receiving When In Use permission
Permission prompt not showing
Permission prompt not showing
Check that:
- Usage description keys are present in
Info.plist - You’re calling the request method on the main thread
- You haven’t already been denied (check authorization status)
- Your
CLLocationManagerinstance isn’t being deallocated
Users downgrading from Always to When In Use
Users downgrading from Always to When In Use
Users can change permissions in Settings at any time. Monitor authorization changes with the delegate callback and adjust your app’s behavior accordingly.