2016-06-22 2 views
0

didUpdateLocations가 호출되지 않고 대신 didFailWithError가 거부 된 코드 kCLErrorDenied과 함께 호출됩니다.didUpdateLocations가 ios 9.3.2에서 호출되지 않았습니다.

#import "ViewController.h" 
@import CoreLocation; 

@interface ViewController() <CLLocationManagerDelegate> 
@property (strong, nonatomic) CLLocationManager *locationManager; 
@end 

@implementation ViewController 

- (void)viewDidLoad { 

    [super viewDidLoad]; 

    // Do any additional setup after loading the view, typically from a nib. 

    self.locationManager = [[CLLocationManager alloc] init]; 

    self.locationManager.delegate = self; 

    // Check for iOS 8. Without this guard the code will crash with "unknown selector" on iOS 7. 

    if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { 

     [self.locationManager requestWhenInUseAuthorization]; 

    } 

    [self.locationManager startUpdatingLocation]; 
} 

- (void)didReceiveMemoryWarning { 

    [super didReceiveMemoryWarning]; 

    // Dispose of any resources that can be recreated. 

} 

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(nonnull NSArray<CLLocation *> *)locations 

{ 

    NSLog(@"update"); 

} 

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(nonnull NSError *)error 

{ 

    NSLog(@"error"); 
} 

@end 

이 응용 프로그램의 Info.plist 파일에 NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescription을 삽입 : 여기에 내가했던 것들입니다. 위치 업데이트가 선택된 기능의 백그라운드 모드를 활성화했습니다. 매우 유명한 블로그 post에서 도움을 얻으십시오. 위치 액세스 요청 팝업을 수신하고 앱이 위치에 액세스하도록 허용합니다.

하지만 위치 업데이트를 관리 할 수 ​​없습니다. IOS 8에서는 IPAD에서 작동하지만 IOS 버전 9.3.2에서는 ipad에서 작동하지 않습니다. IOS 9.3.2에서 어떻게 위치 업데이트가 작동합니까?

+0

: 여기에 세부 검사의 답을

? –

+0

@Ronak Chaniyara 질문이 업데이트되었습니다. kCLErrorDenied가 발생했습니다 (오류 도메인 = kCLErrorDomain 코드 = 0 "(null)") – Murat

답변

0

문제가 해결 될 수 있습니다 다음과 같은 일을 시도 : 당신이있는 경우,

또한

  • 시뮬레이터를 다시 시작하여 네트워크 설정
  • 를 다시 설정으로 이동하여 위치 서비스를 다시

  • +0

    디버깅을 위해 실제 장치를 사용하고 있습니다. 시뮬레이터에서 위치 시뮬레이션 허용과 함께 작동하지만 실제 장치에서는 작동하지 않습니다. 내 질문에 언급 한대로 NSLocationAlwaysUsageDescription 및 NSLocationWhenInUseUsageDescription plist 추가했습니다. 거의 모든 stackoverflow 게시물을 읽었지만 솔루션을 찾을 수 없었습니다. 네가 말했지만 일하지 않는 것들을 적용했다. – Murat

    관련 문제