Skip to content

Commit fa8cb39

Browse files
NathanWalkerclaude
andcommitted
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>
1 parent 22fbbcb commit fa8cb39

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

packages/geolocation/index.android.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function _requestLocationPermissions(always: boolean): Promise<void> {
128128
successCallback = (value) => {
129129
permissions
130130
.request('location', {
131-
type: 'always',
131+
background: true,
132132
})
133133
.then(() => {
134134
resolve();
@@ -145,7 +145,6 @@ function _requestLocationPermissions(always: boolean): Promise<void> {
145145
// App has to request for foreground location permissions first, and request for background permissions afterwards if needed
146146
permissions
147147
.request('location', {
148-
type: '',
149148
coarse: true,
150149
precise: true,
151150
})
@@ -272,7 +271,7 @@ export function enableLocationRequest(always?: boolean, openSettingsIfLocationHa
272271
}
273272
}
274273
reject(new Error('Cannot enable the location service. ' + ex));
275-
}
274+
},
276275
);
277276
}, reject);
278277
}, reject);
@@ -356,14 +355,14 @@ function _systemDialogWillShow(always: boolean): boolean {
356355
async function _permissionIsGiven(always: boolean): Promise<boolean> {
357356
const accessBackground = await permissions.check('android.permission.ACCESS_BACKGROUND_LOCATION');
358357
const accessFine = await permissions.check('android.permission.ACCESS_FINE_LOCATION');
359-
return always ? authorizedStatus.includes(accessBackground[0]) && accessBackground[1] : authorizedStatus.includes(accessFine[0]) && accessFine[1];
358+
return always ? authorizedStatus.includes(accessBackground) : authorizedStatus.includes(accessFine);
360359
}
361360

362361
async function hasFineAndCoursePermission(): Promise<boolean> {
363362
const accessFine = await permissions.check('android.permission.ACCESS_FINE_LOCATION');
364363
const accessCourse = await permissions.check('android.permission.ACCESS_COARSE_LOCATION');
365-
const hasAccessFine = authorizedStatus.includes(accessFine[0]) && accessFine[1] === true;
366-
const hasAccessCourse = authorizedStatus.includes(accessCourse[0]) && accessCourse[1] === true;
364+
const hasAccessFine = authorizedStatus.includes(accessFine);
365+
const hasAccessCourse = authorizedStatus.includes(accessCourse);
367366
return hasAccessFine && hasAccessCourse;
368367
}
369368

@@ -382,7 +381,7 @@ export function isEnabled(options?: Options): Promise<boolean> {
382381
return resolve(true);
383382
}
384383
resolve(false);
385-
}
384+
},
386385
);
387386
}
388387
});

packages/geolocation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
"readmeFilename": "README.md",
3434
"bootstrapper": "@nativescript/plugin-seed",
3535
"dependencies": {
36-
"@nativescript-community/perms": "^2.3.1"
36+
"@nativescript-community/perms": "^3.0.4"
3737
}
3838
}

0 commit comments

Comments
 (0)