Location service iOS alert call back

后端 未结 3 708
迷失自我
迷失自我 2020-12-17 23:56

When we use location services in an application, we receive an iOS alert saying the application is trying to use the current location -- Allow/Don\'t Allow.

Do we h

3条回答
  •  独厮守ぢ
    2020-12-18 00:12

    You can simply get the action selected like below:

    - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
        if (status == kCLAuthorizationStatusAuthorizedAlways || status == kCLAuthorizationStatusAuthorizedWhenInUse) {
            [self addRegion];
        }
        else if (status == kCLAuthorizationStatusDenied) {
            NSLog(@"Location access denied");
        }
    }
    

    make sure to set the delegate of location manager.

提交回复
热议问题