Fix getCurrentPosition

Summary:
Instantiates the _pendingRequests array before trying to add to it. As it currently stands, we try to add the pending request before the array is created. getCurrentPosition always fails on the first try.
Closes https://github.com/facebook/react-native/pull/4764

Reviewed By: svcscm

Differential Revision: D2764751

Pulled By: androidtrunkagent

fb-gh-sync-id: 411a03ff16d40725d8cc0909607632045eb5a27b
This commit is contained in:
Marc Shilling 2015-12-16 08:37:00 -08:00 committed by facebook-github-bot-0
parent 92fb0c44d0
commit f48dbbecd6

View File

@ -130,7 +130,6 @@ RCT_EXPORT_MODULE()
_locationManager = [CLLocationManager new];
_locationManager.distanceFilter = RCT_DEFAULT_LOCATION_ACCURACY;
_locationManager.delegate = self;
_pendingRequests = [NSMutableArray new];
}
// Request location access permission
@ -234,6 +233,9 @@ RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options
selector:@selector(timeout:)
userInfo:request
repeats:NO];
if (!_pendingRequests) {
_pendingRequests = [NSMutableArray new];
}
[_pendingRequests addObject:request];
// Configure location manager and begin updating location