This article introduces the solution to positioning authorization in iOS11 and shares it with you. The details are as follows:
Front Desk Positioning Permissions
1. Add NSLocationWhenInUseUsageDescription.
2. Create a CLLocationManager object and call requestWhenInUseAuthorization() before using the location service.
3. Handle permission changes through func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus). This function will not be called after each change of permissions.
refer to:
/documentation/corelocation/choosing_the_authorization_level_for_location_services/requesting_when_in_use_authorization
Front and backend positioning permissions
If you want to use positioning services in the app in the foreground and backend, you need to complete the following points:
1. Add NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUsageDescription in plist. If you need to support iOS 10, add NSLocationAlwaysUsageDescription.
2. Create a CLLocationManager object, use requestWhenInUseAuthorization() to obtain basic positioning support, and use requestAlwaysAuthorization() to obtain front-end and back-end positioning support.
3. When requestAlwaysAuthorization() is called for the first time, the text specified in NSLocationAlwaysAndWhenInUsageDescription will be prompted to allow the user to choose whether to upgrade to full permissions or foreground permissions.
4. Handle permission changes through func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus). This function will not be called after each change of permissions.
refer to:
/documentation/corelocation/choosing_the_authorization_level_for_location_services/request_always_authorization
Notice:
requestWhenInUseAuthorization dialog box will only pop up when the user is not selected.
* When +authorizationStatus != kCLAuthorizationStatusNotDetermined, (ie
* generally after the first call) this method will do nothing.
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.