简体   繁体   中英

iPhone check location services

I have an app with location services. If I disable location services in preferences, I check this state with this method: [CLLocationManager locationServicesEnabled] This method return if are all location services enabled or disabled. But problem is that I don't know, how to check state of location service for my app. I mean state when are all location services enabled and disabled is only my app ? How can I check this ? [CLLocationManager locationServicesEnabled] not working here ... Thanks a lot ..

Returns the application's authorization status for using location services.

+ (CLAuthorizationStatus)authorizationStatus

Return Value

A value indicating whether the application is authorized to use location services.

I use this in my code, and it work fine

if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized ) 
{
    //do something
}
else 
{
    //display an alert for example
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM