From fa8cb3969502626b5217a51776003416dff793cd Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Mon, 24 Aug 2026 08:52:42 -0700 Subject: [PATCH] feat(geolocation)!: migrate to @nativescript-community/perms v3 perms v3 changed `check()`/`request()` to resolve to a `Status` string instead of the v2 `[Status, boolean]` tuple, and renamed the location `type: 'always'` option to `background: true`. Under v3 the old tuple reads silently degraded rather than failing: `authorizedStatus.includes(accessFine[0])` tested the first *character* of the status string, so `isEnabled()` always resolved false. BREAKING CHANGE: requires @nativescript-community/perms v3. Apps pinning perms v2 must upgrade alongside this release. Co-Authored-By: Claude Opus 5 (1M context) --- packages/geolocation/index.android.ts | 13 ++++++------- packages/geolocation/package.json | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/geolocation/index.android.ts b/packages/geolocation/index.android.ts index 3521cc8c..809508f5 100644 --- a/packages/geolocation/index.android.ts +++ b/packages/geolocation/index.android.ts @@ -128,7 +128,7 @@ function _requestLocationPermissions(always: boolean): Promise { successCallback = (value) => { permissions .request('location', { - type: 'always', + background: true, }) .then(() => { resolve(); @@ -145,7 +145,6 @@ function _requestLocationPermissions(always: boolean): Promise { // App has to request for foreground location permissions first, and request for background permissions afterwards if needed permissions .request('location', { - type: '', coarse: true, precise: true, }) @@ -272,7 +271,7 @@ export function enableLocationRequest(always?: boolean, openSettingsIfLocationHa } } reject(new Error('Cannot enable the location service. ' + ex)); - } + }, ); }, reject); }, reject); @@ -356,14 +355,14 @@ function _systemDialogWillShow(always: boolean): boolean { async function _permissionIsGiven(always: boolean): Promise { const accessBackground = await permissions.check('android.permission.ACCESS_BACKGROUND_LOCATION'); const accessFine = await permissions.check('android.permission.ACCESS_FINE_LOCATION'); - return always ? authorizedStatus.includes(accessBackground[0]) && accessBackground[1] : authorizedStatus.includes(accessFine[0]) && accessFine[1]; + return always ? authorizedStatus.includes(accessBackground) : authorizedStatus.includes(accessFine); } async function hasFineAndCoursePermission(): Promise { const accessFine = await permissions.check('android.permission.ACCESS_FINE_LOCATION'); const accessCourse = await permissions.check('android.permission.ACCESS_COARSE_LOCATION'); - const hasAccessFine = authorizedStatus.includes(accessFine[0]) && accessFine[1] === true; - const hasAccessCourse = authorizedStatus.includes(accessCourse[0]) && accessCourse[1] === true; + const hasAccessFine = authorizedStatus.includes(accessFine); + const hasAccessCourse = authorizedStatus.includes(accessCourse); return hasAccessFine && hasAccessCourse; } @@ -382,7 +381,7 @@ export function isEnabled(options?: Options): Promise { return resolve(true); } resolve(false); - } + }, ); } }); diff --git a/packages/geolocation/package.json b/packages/geolocation/package.json index 1482db62..a906a18a 100644 --- a/packages/geolocation/package.json +++ b/packages/geolocation/package.json @@ -33,6 +33,6 @@ "readmeFilename": "README.md", "bootstrapper": "@nativescript/plugin-seed", "dependencies": { - "@nativescript-community/perms": "^2.3.1" + "@nativescript-community/perms": "^3.0.4" } }