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

Commit 908196a

Browse files
Dimitar TachevDimitar Tachev
authored andcommitted
fix(android): handle only exceptions of the proper type on enable location
1 parent 8070102 commit 908196a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/geolocation.android.ts

Lines changed: 5 additions & 2 deletions
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);

0 commit comments

Comments
 (0)