From 779f9e2b9ccb9a729321490ac8562d1b46aeb87a Mon Sep 17 00:00:00 2001 From: Rob Hogan Date: Wed, 21 Sep 2016 14:27:49 -0700 Subject: [PATCH] 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 --- Libraries/Geolocation/RCTLocationObserver.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Geolocation/RCTLocationObserver.m b/Libraries/Geolocation/RCTLocationObserver.m index e09cad5dc..dc99ed193 100644 --- a/Libraries/Geolocation/RCTLocationObserver.m +++ b/Libraries/Geolocation/RCTLocationObserver.m @@ -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];