Let's think about it this way for a second
We already covered adding a usage description string in `Info.plist` back in the Basics chapter — calling an iOS API (Camera, Location) automatically shows the system dialog (unlike Android, where you'd need to manually trigger something like `rememberLauncherForActivityResult`), and the user can choose 'Allow' or 'Don't Allow'. Location permission can be split into two levels of granularity: 'While Using App' / 'Always' — App Store review checks 'Always' (background location) especially strictly.
Let's connect this to a real-world scenario
In an app with a location feature, calling `CLLocationManager().requestWhenInUseAuthorization()` immediately brings up a system dialog containing the `NSLocationWhenInUseUsageDescription` string from `Info.plist` — you can only get location data once the user taps 'Allow', and if they choose 'Don't Allow' you need to handle that gracefully.
Let's look at it together
import CoreLocation
class LocationManager: NSObject, ObservableObject {
private let manager = CLLocationManager()
override init() {
super.init()
manager.delegate = self
}
func requestPermission() {
manager.requestWhenInUseAuthorization()
}
}
extension LocationManager: CLLocationManagerDelegate {
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
print("Authorization status: \(manager.authorizationStatus)")
}
}Calling `requestPermission()` brings up the system location permission dialog, and choosing 'Allow' shows authorizationStatus changing in the Console.5-minute try-it
Write your own `LocationManager`, add `NSLocationWhenInUseUsageDescription` to `Info.plist`, and trigger the permission dialog on the Simulator — try choosing both 'Allow' and 'Don't Allow'.
A quick heads-up
Once the user picks 'Don't Allow', your app can't show the dialog again — they'll need to go to Settings manually, so your app should show guidance like 'please open Settings'.