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ファイルにNSLocationWhenInUseUsageDescription
とNSLocationAlwaysUsageDescription
を挿入: は、ここで私がやったものです。場所の更新が選択された機能の背景モードを有効にしました。非常に有名なブログpostから助けを得てください。私はLocation Access Requestポップアップを受け取り、アプリケーションが場所にアクセスできるようにします。
しかし、私は位置の更新を取得できませんでした。それはIOS 8でIPADで動作しますが、IOSバージョン9.3.2でipadで動作しません。 IOS 9.3.2でロケーションアップデートを動作させるにはどうすればよいですか?以下の事をしようと
それはdidFailWithError' 'になりますどのようなエラー? –
@Ronak Chaniyara質問を更新しました。私はkCLErrorDeniedを取得します(エラードメイン= kCLErrorDomainコード= 0 "(ヌル)") – Murat