From 5c17db8352abfd94f094deb9b550284ec17f1fcd Mon Sep 17 00:00:00 2001 From: ngandhy Date: Fri, 12 Jan 2018 18:48:10 -0800 Subject: [PATCH] re #17486 - set _locationManager if auth skipped Summary: This fixes #17486 make sure locationManager is being set before continuing. Used if !locationManager vs else on previous statement as we should NEVER enter this code without _locationManager set. Also the else version might experience issues if someone touches the auth code and doesn't check this case, so seems more "long term stable". This fixes #17486 1) Have a working geolocation demo 2) Add navigator.geolocation.setRNConfiguration({'skipPermissionRequests':true}); to your code. I added it to the constructor or componentWillMount for the app. 3) Observe that geolocation no longer works (times out) 4) Apply patch 5) Observe that geolocation works again re #15096 [IOS] [BUGFIX] [GeoLocation] - Fix skipPermissionRequests by setting _locationManager Closes https://github.com/facebook/react-native/pull/17487 Differential Revision: D6718389 Pulled By: hramos fbshipit-source-id: 08c1c9306b4d87cc40acdaa1550bb6df8345db02 --- Libraries/Geolocation/RCTLocationObserver.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Libraries/Geolocation/RCTLocationObserver.m b/Libraries/Geolocation/RCTLocationObserver.m index 4ea8a57dc1ea56..11b344a6f46cf1 100644 --- a/Libraries/Geolocation/RCTLocationObserver.m +++ b/Libraries/Geolocation/RCTLocationObserver.m @@ -158,6 +158,11 @@ - (void)beginLocationUpdatesWithDesiredAccuracy:(CLLocationAccuracy)desiredAccur if (!_locationConfiguration.skipPermissionRequests) { [self requestAuthorization]; } + + if (!_locationManager) { + _locationManager = [CLLocationManager new]; + _locationManager.delegate = self; + } _locationManager.distanceFilter = distanceFilter; _locationManager.desiredAccuracy = desiredAccuracy;