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

Commit 7f3570f

Browse files
authored
Merge pull request #105 from NativeScript/tachev/fix-issue-93
fix(android): handle only exceptions of the proper type on enable location
2 parents 8070102 + 8346f02 commit 7f3570f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/geolocation.android.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,12 @@ export function enableLocationRequest(always?: boolean): Promise<void> {
176176
_isLocationServiceEnabled().then(() => {
177177
resolve();
178178
}, (ex) => {
179-
let statusCode = ex.getStatusCode();
180-
if (statusCode === com.google.android.gms.common.api.CommonStatusCodes.RESOLUTION_REQUIRED) {
179+
if (typeof ex.getStatusCode === "function" &&
180+
ex.getStatusCode() === com.google.android.gms.common.api.CommonStatusCodes.RESOLUTION_REQUIRED) {
181+
181182
try {
183+
// cache resolve and reject callbacks in order to call them
184+
// on REQUEST_ENABLE_LOCATION Activity Result
182185
_onEnableLocationSuccess = resolve;
183186
_onEnableLocationFail = reject;
184187
ex.startResolutionForResult(androidAppInstance.foregroundActivity, REQUEST_ENABLE_LOCATION);

src/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-geolocation",
3-
"version": "4.2.2",
3+
"version": "4.2.3",
44
"description": "Provides API for getting and monitoring location for NativeScript app.",
55
"main": "geolocation",
66
"nativescript": {

0 commit comments

Comments
 (0)