From 5ecd0eb8323242e94cc74ba838067b4a4b77136f Mon Sep 17 00:00:00 2001 From: Zdravko Date: Thu, 7 Mar 2019 17:00:55 +0200 Subject: [PATCH] Revert "fix ios accuracy" --- demo/app/tests/mock-ios.js | 8 -------- src/geolocation.ios.ts | 34 ++++++---------------------------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/demo/app/tests/mock-ios.js b/demo/app/tests/mock-ios.js index 11dd776..c1f9df3 100644 --- a/demo/app/tests/mock-ios.js +++ b/demo/app/tests/mock-ios.js @@ -19,14 +19,6 @@ var MockLocationManager = (function () { return _this._requestSingleUpdate(_this.delegate, _this); }, 500); }; - MockLocationManager.prototype.requestLocation = function () { - var _this = this; - this.removeUpdates(null); - MockLocationManager.intervalId = setTimeout(function () { - // this.delegate is the location listener - return _this._requestSingleUpdate(_this.delegate, _this); - }, 500); - }; MockLocationManager.prototype._requestSingleUpdate = function (locListener, instance) { var newLocation = { coordinate: { diff --git a/src/geolocation.ios.ts b/src/geolocation.ios.ts index 3812d00..97d900d 100644 --- a/src/geolocation.ios.ts +++ b/src/geolocation.ios.ts @@ -140,10 +140,6 @@ function errorHandler(errData: UnhandledErrorEventData) { } } -function getVersionMaj () { - return parseInt(Platform.device.osVersion.split(".")[0]); -} - // options - desiredAccuracy, updateDistance, minimumUpdateTime, maximumAge, timeout export function getCurrentLocation(options: Options): Promise { return new Promise(function (resolve, reject) { @@ -168,7 +164,6 @@ export function getCurrentLocation(options: Options): Promise { } else { let timerId; let locListener; - let initLocation; let stopTimerAndMonitor = function (locListenerId) { if (timerId !== undefined) { @@ -179,30 +174,18 @@ export function getCurrentLocation(options: Options): Promise { }; let successCallback = function (location: Location) { - if (getVersionMaj() < 9) { - if (typeof options.maximumAge === "number" && location.timestamp.valueOf() + options.maximumAge < new Date().valueOf()) { - // returned location is too old, but we still have some time before the timeout so maybe wait a bit? - return; - } - - if (options.desiredAccuracy !== Accuracy.any && !initLocation) { - // regardless of desired accuracy ios returns first location as quick as possible even if not as accurate as requested - initLocation = location; - return; - } + if (typeof options.maximumAge === "number" && location.timestamp.valueOf() + options.maximumAge < new Date().valueOf()) { + // returned location is too old, but we still have some time before the timeout so maybe wait a bit? + return; } stopTimerAndMonitor(locListener.id); resolve(location); }; - locListener = LocationListenerImpl.initWithLocationError(successCallback, reject); + locListener = LocationListenerImpl.initWithLocationError(successCallback); try { - if (getVersionMaj() >= 9) { - LocationMonitor.requestLocation(options, locListener); - } else { - LocationMonitor.startLocationMonitoring(options, locListener); - } + LocationMonitor.startLocationMonitoring(options, locListener); } catch (e) { stopTimerAndMonitor(locListener.id); reject(e); @@ -338,11 +321,6 @@ export class LocationMonitor { return null; } - static requestLocation(options: Options, locListener: any): void { - let iosLocManager = getIOSLocationManager(locListener, options); - iosLocManager.requestLocation(); - } - static startLocationMonitoring(options: Options, locListener: any): void { let iosLocManager = getIOSLocationManager(locListener, options); iosLocManager.startUpdatingLocation(); @@ -364,7 +342,7 @@ export class LocationMonitor { iosLocManager.distanceFilter = options ? options.updateDistance : minRangeUpdate; locationManagers[locListener.id] = iosLocManager; locationListeners[locListener.id] = locListener; - if (getVersionMaj() >= 9) { + if (parseInt(Platform.device.osVersion.split(".")[0]) >= 9) { iosLocManager.allowsBackgroundLocationUpdates = options && options.iosAllowsBackgroundLocationUpdates != null ? options.iosAllowsBackgroundLocationUpdates : false;