IOS Turn on location services using the Settings and Cancel buttons. How to make a "Capture Cancel" button.

When the user launches the application for the first time and tries to log in, he is offered the iOS dialog - "Enable location services."

I need to capture when the user clicks "cancel". Is it Notificationsent? If so, what is his name? I could not find him.

CLAUthorizationStatus kCLAuthorizationDeniedif location services are disabled or the user clicked the "Do not allow" button. When the user clicks "Cancel", he does not fire the event authorizationChange. When the user clicks "Cancel", the application simply freezes.

+4
source share
1 answer

Short answer: you cannot catch this notice. You can conclude about the choice of the user and act using methods CLLocationManager(longer answer below).

Longer answer:

First, welcome to stack overflow. Before you volunteer to ask your question and try to work with people who are here to help, it is a good idea to look if someone else has asked the same question before.

A brief search yielded (only for some of them):

, iOS docs:

, UIRequiredDeviceCapabilities Info.plist. , . App Store , , .

. , , UIRequiredDeviceCapabilities.

, , location-services gps UIRequiredDeviceCapabilities.

, - - , .

[CLLocationManager locationServicesEnabled]

:

  • "".
  • .
  • .

: .

, :

. . , . , CLLocationManager . authorizationStatus.

[CLLocationManager authorizationStatus]

:

  • kCLAuthorizationStatusNotDetermined, , .
  • kCLAuthorizationStatusRestricted . , , - , , .
  • kCLAuthorizationStatusDenied .
  • kCLAuthorizationStatusAuthorized .

[CLLocationManager locationServicesEnabled] NO, (.. [locationManager startUpdatingLocation]), , . , , , , .

, , ( , authorizationStatus).. , , . , . , ? - , .

[locationManager startUpdatingLocation], , locationManager: didFailWithError: kCLErrorDenied.

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error

UIAlert, , .


, , : , " " ".

, , , "" / " ", .

, , , , .

Post scriptum: , , , , .

+14

Source: https://habr.com/ru/post/1523535/


All Articles