Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 7cd49eb

Browse files
authored
Merge pull request #191 from NativeScript/tbozhikov/fix-wrong-rejection
fix: wrong rejection when using always option on enableLocationRequest()
2 parents b52682b + da71c99 commit 7cd49eb

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

demo/app/main-page.ts

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export function enableLocationTap() {
6262
geolocation.isEnabled().then(function (isEnabled) {
6363
if (!isEnabled) {
6464
geolocation.enableLocationRequest(false, true).then(function () {
65+
console.log("allowed location usage");
6566
}, function (e) {
6667
console.log("Error: " + (e.message || e));
6768
});

src/geolocation.ios.ts

+1-13
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,10 @@ class LocationListenerImpl extends NSObject implements CLLocationManagerDelegate
8585
break;
8686

8787
case CLAuthorizationStatus.kCLAuthorizationStatusAuthorizedAlways:
88-
if (this.authorizeAlways && this._resolve) {
89-
LocationMonitor.stopLocationMonitoring(this.id);
90-
this._resolve();
91-
} else if (this._reject) {
92-
LocationMonitor.stopLocationMonitoring(this.id);
93-
this._reject(new Error("Authorization Denied."));
94-
}
95-
break;
96-
9788
case CLAuthorizationStatus.kCLAuthorizationStatusAuthorizedWhenInUse:
98-
if (!this.authorizeAlways && this._resolve) {
89+
if (this._resolve) {
9990
LocationMonitor.stopLocationMonitoring(this.id);
10091
this._resolve();
101-
} else if (this._reject) {
102-
LocationMonitor.stopLocationMonitoring(this.id);
103-
this._reject(new Error("Authorization Denied."));
10492
}
10593
break;
10694

0 commit comments

Comments
 (0)