diff --git a/src/geolocation.android.ts b/src/geolocation.android.ts index 5362d82..7c5f082 100644 --- a/src/geolocation.android.ts +++ b/src/geolocation.android.ts @@ -176,9 +176,12 @@ export function enableLocationRequest(always?: boolean): Promise { _isLocationServiceEnabled().then(() => { resolve(); }, (ex) => { - let statusCode = ex.getStatusCode(); - if (statusCode === com.google.android.gms.common.api.CommonStatusCodes.RESOLUTION_REQUIRED) { + if (typeof ex.getStatusCode === "function" && + ex.getStatusCode() === com.google.android.gms.common.api.CommonStatusCodes.RESOLUTION_REQUIRED) { + try { + // cache resolve and reject callbacks in order to call them + // on REQUEST_ENABLE_LOCATION Activity Result _onEnableLocationSuccess = resolve; _onEnableLocationFail = reject; ex.startResolutionForResult(androidAppInstance.foregroundActivity, REQUEST_ENABLE_LOCATION); diff --git a/src/package.json b/src/package.json index da833a2..e2310bc 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-geolocation", - "version": "4.2.2", + "version": "4.2.3", "description": "Provides API for getting and monitoring location for NativeScript app.", "main": "geolocation", "nativescript": {