Skip to content

Commit 129d044

Browse files
Set default timeout to 10 minutes (#230)
* fix: set default timeout to 10 mins * docs: update default timeout documentation * fix: bad paste
1 parent 9324cbc commit 129d044

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Invokes the success callback once with the latest location info.
206206

207207
Supported options:
208208

209-
* `timeout` (ms) - Is a positive value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. Defaults to INFINITY.
209+
* `timeout` (ms) - Is a positive value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. Defaults to 10 minutes.
210210
* `maximumAge` (ms) - Is a positive value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return. If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position. If set to Infinity the device will always return a cached position regardless of its age. Defaults to INFINITY.
211211
* `enableHighAccuracy` (bool) - Is a boolean representing if to use GPS or not. If set to true, a GPS position will be requested. If set to false, a WIFI location will be requested.
212212

@@ -257,7 +257,7 @@ Supported options:
257257

258258
* `interval` (ms) -- (Android only) The rate in milliseconds at which your app prefers to receive location updates. Note that the location updates may be somewhat faster or slower than this rate to optimize for battery usage, or there may be no updates at all (if the device has no connectivity, for example).
259259
* `fastestInterval` (ms) -- (Android only) The fastest rate in milliseconds at which your app can handle location updates. Unless your app benefits from receiving updates more quickly than the rate specified in `interval`, you don't need to set it.
260-
* `timeout` (ms) - Is a positive value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. Defaults to INFINITY.
260+
* `timeout` (ms) - Is a positive value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. Defaults to 10 minutes.
261261
* `maximumAge` (ms) - Is a positive value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return. If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position. If set to Infinity the device will always return a cached position regardless of its age. Defaults to INFINITY.
262262
* `enableHighAccuracy` (bool) - Is a boolean representing if to use GPS or not. If set to true, a GPS position will be requested. If set to false, a WIFI location will be requested.
263263
* `distanceFilter` (m) - The minimum distance from the previous location to exceed before returning a new location. Set to 0 to not filter locations. Defaults to 100m.

android/src/main/java/com/reactnativecommunity/geolocation/BaseLocationManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected static LocationOptions fromReactMap(ReadableMap map) {
109109
int fastestInterval =
110110
map.hasKey("fastestInterval") ? map.getInt("fastestInterval") : -1;
111111
long timeout =
112-
map.hasKey("timeout") ? (long) map.getDouble("timeout") : Long.MAX_VALUE;
112+
map.hasKey("timeout") ? (long) map.getDouble("timeout") : 1000 * 60 * 10;
113113
double maximumAge =
114114
map.hasKey("maximumAge") ? map.getDouble("maximumAge") : Double.POSITIVE_INFINITY;
115115
boolean highAccuracy =

ios/RNCGeolocation.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ + (RNCGeolocationOptions)RNCGeolocationOptions:(id)json
7575
: [RCTConvert double:options[@"distanceFilter"]] ?: kCLDistanceFilterNone;
7676

7777
return (RNCGeolocationOptions){
78-
.timeout = [RCTConvert NSTimeInterval:options[@"timeout"]] ?: INFINITY,
78+
.timeout = [RCTConvert NSTimeInterval:options[@"timeout"]] ?: 1000 * 60 * 10,
7979
.maximumAge = [RCTConvert NSTimeInterval:options[@"maximumAge"]] ?: INFINITY,
8080
.accuracy = [RCTConvert BOOL:options[@"enableHighAccuracy"]] ? kCLLocationAccuracyBest : RNC_DEFAULT_LOCATION_ACCURACY,
8181
.distanceFilter = distanceFilter,

0 commit comments

Comments
 (0)