diff --git a/Libraries/Geolocation/RCTLocationObserver.m b/Libraries/Geolocation/RCTLocationObserver.m index 6ea912e45c1db4..63ceb7c9d95d64 100644 --- a/Libraries/Geolocation/RCTLocationObserver.m +++ b/Libraries/Geolocation/RCTLocationObserver.m @@ -133,7 +133,11 @@ - (void)beginLocationUpdates } // Request location access permission - if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { + if ([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"] && + [_locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) { + [_locationManager requestAlwaysAuthorization]; + } else if ([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"] && + [_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { [_locationManager requestWhenInUseAuthorization]; } @@ -327,8 +331,9 @@ - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError * - (void)checkLocationConfig { - if (![[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]) { - RCTLogError(@"NSLocationWhenInUseUsageDescription key must be present in Info.plist to use geolocation."); + if (!([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"] || + [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"])) { + RCTLogError(@"Either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription key must be present in Info.plist to use geolocation."); } }