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

Commit

Permalink
Merge pull request #105 from NativeScript/tachev/fix-issue-93
Browse files Browse the repository at this point in the history
fix(android): handle only exceptions of the proper type on enable location
  • Loading branch information
lini authored Jan 23, 2018
2 parents 8070102 + 8346f02 commit 7f3570f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/geolocation.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@ export function enableLocationRequest(always?: boolean): Promise<void> {
_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);
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 7f3570f

Please sign in to comment.