当前位置: 首页 > 面试题库 >

Checking location service permission on iOS

慕璞
2023-03-14
问题内容

How can I check if location service is enabled for my app?

I have 2 storyboards and I want to check location service. If location service
enabled for my app, I want to launch map storyboard with location. Otherwise,
I want to launch another storyboard. How can I do programmatically?


问题答案:

This is the correct.

if ([CLLocationManager locationServicesEnabled]){

    NSLog(@"Location Services Enabled");

    if ([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied){
        alert = [[UIAlertView alloc] initWithTitle:@"App Permission Denied"     
                                           message:@"To re-enable, please go to Settings and turn on Location Service for this app." 
                                          delegate:nil 
                                 cancelButtonTitle:@"OK" 
                                 otherButtonTitles:nil];
        [alert show];
    }
}


 类似资料:

相关阅读

相关文章

相关问答