Visitar URL original
feat(geolocation)!: migrate to @nativescript-community/perms v3 by NathanWalker · Pull Request #675 · NativeScript/plugins · GitHub
Skip to content
Open
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
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) <noreply@anthropic.com>
  • Loading branch information
NathanWalker and claude committed Aug 24, 2026
commit fa8cb3969502626b5217a51776003416dff793cd
13 changes: 6 additions & 7 deletions packages/geolocation/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function _requestLocationPermissions(always: boolean): Promise<void> {
successCallback = (value) => {
permissions
.request('location', {
type: 'always',
background: true,
})
.then(() => {
resolve();
Expand All @@ -145,7 +145,6 @@ function _requestLocationPermissions(always: boolean): Promise<void> {
// 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,
})
Expand Down Expand Up @@ -272,7 +271,7 @@ export function enableLocationRequest(always?: boolean, openSettingsIfLocationHa
}
}
reject(new Error('Cannot enable the location service. ' + ex));
}
},
);
}, reject);
}, reject);
Expand Down Expand Up @@ -356,14 +355,14 @@ function _systemDialogWillShow(always: boolean): boolean {
async function _permissionIsGiven(always: boolean): Promise<boolean> {
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<boolean> {
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;
}

Expand All @@ -382,7 +381,7 @@ export function isEnabled(options?: Options): Promise<boolean> {
return resolve(true);
}
resolve(false);
}
},
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/geolocation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"readmeFilename": "README.md",
"bootstrapper": "@nativescript/plugin-seed",
"dependencies": {
"@nativescript-community/perms": "^2.3.1"
"@nativescript-community/perms": "^3.0.4"
}
}