0

我开发了一个应用程序,我试图在委托方法“applicationDidBecomeActive”中获取当前设备位置并且它工作正常,但是当我在 Xcode 8 beta 6 和 iOS beta 10.7 上测试我的相同代码时出现了问题。屏幕被连续的警报轰炸,说“允许“应用程序”在您使用应用程序时访问您的位置”。我无法单击“允许”/“不允许”。我的代码是:

-(void) startLocationService {
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];

if (![CLLocationManager locationServicesEnabled] || status == kCLAuthorizationStatusDenied || status == kCLAuthorizationStatusRestricted) {
    DLog(@"Locations disabled or status not permiting use of locations systems.");
    self.currentLocation = nil;
    [self sendNotificationforErrorMessage:ERROR_MSG_LOCATION_SERVICE];
}
else {
    [self createLocationManager];

    if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
        if (status == kCLAuthorizationStatusNotDetermined) {
            [locationManager requestWhenInUseAuthorization];
        }
    }
    else {
        [self startLocationManager];
    }
}
}

-(void)createLocationManager {
self.currentLocation = nil;
locationManager = [[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
locationManager.delegate = self;
}

-(void)startLocationManager {
[locationManager startUpdatingLocation];
[self performSelector:@selector(locationServiceTimedout)
           withObject:nil
           afterDelay:timeOutValue];
}

我测试过的场景: 1) 在 Xcode8 beta6 中编译应用程序并在 iOS 9 设备上成功运行 2) 在 Xcode8 beta6 中编译应用程序并在 iOS10 设备上被警报轰炸。

我试过用谷歌搜索它,但没有运气。任何指针都受到高度赞赏。

4

1 回答 1

0

尝试这个

前往info.plist

添加密钥

Privacy - Location Always Usage Description

或者

Privacy - Location Usage Description

或者

Privacy - Location When In Use Usage Description

在右侧添加说明。

于 2016-08-23T20:52:54.130 回答