El cuadro de dialog de permissions de location le solicita mucho time en iOS 10

en iOS 10, a veces, cuando se instala la aplicación, las indicaciones de permiso de location se abren mucho time y cuelga toda la aplicación y no pueden avanzar más.

aquí está mi código que funciona antes de iOS 10

-(void)startLocationManager{ self.locationManager=[[CLLocationManager alloc]init]; self.locationManager.desinetworkingAccuracy=kCLLocationAccuracyBest; self.locationManager.delegate=self; if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { [self.locationManager requestWhenInUseAuthorization]; } [self.locationManager startUpdatingLocation]; } -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ if (self.myCurrentLocation==nil) { self.myCurrentLocation=[locations lastObject]; [[WALocationManager WALocationShanetworkingInstance] checkLatestLocation]; } else{ if (self.myCurrentLocation.horizontalAccuracy < 0){ return; } self.myCurrentLocation=[locations lastObject]; if([[WALocationManager WALocationShanetworkingInstance] currentLocation]!=self.myCurrentLocation ){ } } } 

En mi file Plist,

 <key>NSLocationAlwaysUsageDescription</key> <string>This app will use your location to get most nearyby activity around you.</string> <key>NSLocationWhenInUseUsageDescription</key> <string>This app will use your location.</string> 

Independientemente de iOS 10, debe comenzar a actualizar su location solo si se otorgó el permiso, también debe comprobar si el permiso ya se ha otorgado antes de solicitar los permissions:

 -(void)startLocationManager{ self.locationManager=[[CLLocationManager alloc]init]; self.locationManager.desinetworkingAccuracy=kCLLocationAccuracyBest; self.locationManager.delegate=self; // Check for current permissions [self checkLocationAuth:[CLLocationManager authorizationStatus]]; } -(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{ [self checkLocationAuth:status]; } -(void)checkLocationAuth:(CLAuthorizationStatus)status{ switch (status) { case kCLAuthorizationStatusAuthorizedWhenInUse: case kCLAuthorizationStatusAuthorizedAlways: [self.locationManager startUpdatingLocation]; break; // did not ask for permission, ask now case kCLAuthorizationStatusNotDetermined: if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { [self.locationManager requestWhenInUseAuthorization]; } else { // iOS < 8? implicitly request permission [self.locationManager startUpdatingLocation]; } break; // Also need to handle failures, etc default: break; } } 

Puede ser que pueda probar a continuación las verificaciones y ver si ayuda:

No llame a requestWhenInUseAuthorization cada vez.

compruebe tanto locationServicesEnabled como authorizationStatus , llame a requestWhenInUseAuthorization solo si authorizationStatus es kCLAuthorizationStatusDenied y locationServicesEnabled devuelve false .

Me gusta,

 if(![CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) { if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { [self.locationManager requestWhenInUseAuthorization]; } } 

Espero que te ayude 🙂