RCTLocationObserver: Fix reporting of timeout error

Summary:
Fixes an issue where location request timeout errors always reported "Unable to fetch location within **0s**".

Previously we had `@"Unable to fetch location within %zds.", (NSInteger)(timer.timeInterval * 1000.0)` but from the [NSTimer.timeInterval docs](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/#//apple_ref/occ/instp/NSTimer/timeInterval) "If the receiver is a non-repeating timer, returns 0 even if a time interval was set.".

Change to use `request.options.timeout` instead, which is a `Double` defaulting to `INFINITY`. Tested on an iOS simulator.
Closes https://github.com/facebook/react-native/pull/9888

Differential Revision: D3902788

Pulled By: javache

fbshipit-source-id: aef717d6c39f3177cb7056a17adc35c1bfd94132
This commit is contained in:
Rob Hogan 2016-09-21 14:27:49 -07:00 committed by Facebook Github Bot 0
parent 1a62b66c51
commit 779f9e2b9c
1 changed files with 1 additions and 1 deletions

View File

@ -160,7 +160,7 @@ RCT_EXPORT_MODULE()
- (void)timeout:(NSTimer *)timer
{
RCTLocationRequest *request = timer.userInfo;
NSString *message = [NSString stringWithFormat: @"Unable to fetch location within %zds.", (NSInteger)(timer.timeInterval * 1000.0)];
NSString *message = [NSString stringWithFormat: @"Unable to fetch location within %.1fs.", request.options.timeout];
request.errorBlock(@[RCTPositionError(RCTPositionErrorTimeout, message)]);
[_pendingRequests removeObject:request];