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

fix(android): handle only exceptions of the proper type on enable location #105

Merged
merged 2 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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