Permalink
Browse files

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 #9888

Differential Revision: D3902788

Pulled By: javache

fbshipit-source-id: aef717d6c39f3177cb7056a17adc35c1bfd94132
  • Loading branch information...
1 parent 1a62b66 commit 779f9e2b9ccb9a729321490ac8562d1b46aeb87a @rh389 rh389 committed with Facebook Github Bot 0 Sep 21, 2016
Showing with 1 addition and 1 deletion.
  1. +1 −1 Libraries/Geolocation/RCTLocationObserver.m
@@ -160,7 +160,7 @@ - (void)beginLocationUpdatesWithDesiredAccuracy:(CLLocationAccuracy)desiredAccur
- (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];

0 comments on commit 779f9e2

Please sign in to comment.