I have found the following solution explaining how to utilize location services in iOS 8. Unfortunately I have got only an iPhone 6 simulator and not the real device. I tried to add this code in the viewDidLoad method but the authorization dialog is never shown. Why is this?
I added a breakpoint in the following, it gets executed but does not show the dialouge..:
// Will open an confirm dialog to get user's approval
[locationManager requestAlwaysAuthorization];
And here is the full viewDidLoad method:
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Initialize location manager
locationManager = [CLLocationManager new];
float system = [[[UIDevice currentDevice] systemVersion] floatValue ];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 &&
[CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorizedAlways
) {
// Will open an confirm dialog to get user's approval
[locationManager requestAlwaysAuthorization];
} else {
[locationManager startUpdatingLocation]; //Will update location immediately
}
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
Aucun commentaire:
Enregistrer un commentaire