I\'m trying to use some fancy iBeacons without success, kCLAuthorizationStatusNotDetermined all time. According to other questions it\'s a requirement to add those keys to
Hardware-dependent System Issue?
iOS 13.1.3, iPhone 7 (model ID "iPhone9,1")
Seems like system Settings->Privacy->Location in some way cache permissions even after app deletion (at least, during the same iOS session and for specified configuration).
If 'allow once' is pressed and user deletes and reinstalls and runs the app again, didChangeAuthorizationStatus(_:) sends initial status .denied. (And therefore, according to CLLocationManager logic it does not show prompt alert after requestAlwaysAuthorization()). This .denied status was the root of the evil in this case.
If user folds the app between initial didChangeAuthorizationStatus(:) and requestAlwaysAuthorization(), this causes next update of didChangeAuthorizationStatus(:) with status other than .denied and prompt alert will be shown.
iOS 13.1.3, iPhone 7 (model ID "iPhone9,3") - issue does not reproduce. (initial status received is .notDetermined)
iOS 13.1.2 iPhone 8 - all ok, same as above
To add to that: be sure you have added the array UIBackgroundModes to your .plist and inserted the "location" value.
Apple will not tell you it is missing and give you WhenInUse instead.
So in summary:
I have noticed that if your instance of CLLocationManager is destroyed before the alert shows, you will never see the alert. In my case I was creating a local variable of the location manager in the AppDelegate to ask for permission.
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[locationManager requestAlwaysAuthorization];
}
Changing the local variable to an instance variable made the alert to display:
@interface AppDelegate () {
CLLocationManager *_locationManager;
}
@end
_locationManager = [[CLLocationManager alloc] init];
if ([_locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[_locationManager requestAlwaysAuthorization];
}
Please check this Reference link
It has described all the changes regarding iOS 11. Your issue is also seems to be one among the cases it described. It might give you an idea what changes you need to make in your code to correct the issue.
Just add this lines to your .plist file
<key>NSLocationAlwaysUsageDescription</key>
<string>Optional message</string>
I got a similar problem recently with IOS 11 when I tried to use
locationManager.requestAlwaysAuthorization()
The solution for me was to add all the 4 permissions in plist.info to get the alert: