ios 11 定位權限沒有彈出

-(void)requestWhenInUseAuthorization {
    if (![self getUserLocationAuth]) {
        self.locationManagerSystem = [[CLLocationManager alloc]init];
        if ([self.locationManagerSystem respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
            [self.locationManagerSystem requestWhenInUseAuthorization];
        }
    }
}

- (BOOL)getUserLocationAuth {
    BOOL result = NO;
    switch ([CLLocationManager authorizationStatus]) {
        case kCLAuthorizationStatusNotDetermined: //用戶沒有選擇是否要使用定位服務(彈框沒選擇,或者根本沒有彈框)
            break;
        case kCLAuthorizationStatusRestricted: //定位服務授權狀態受限制,可能由於活動限制了定位服務,並且用戶不能改變當前的權限,這個狀態有可能不是用戶拒絕的,但是也有可能是用戶拒絕的
            break;
        case kCLAuthorizationStatusDenied: //用戶在設置中關閉定位功能,或者用戶明確的在彈框之後選擇禁止定位
            [self openAlertView];
            break;
        case kCLAuthorizationStatusAuthorizedAlways:
            result = YES;
            break;
        case kCLAuthorizationStatusAuthorizedWhenInUse:
            result = YES;
            break;
            
        default:
            break;
    }
    return result;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章