From 9d76c0670835e4189e9254da7f6f5cd5b6595c63 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Mon, 24 Aug 2026 08:53:55 -0700 Subject: [PATCH] feat(imagepicker)!: migrate to @nativescript-community/perms v3 perms v3 changed single-permission `request()` to resolve to a `Status` string instead of the v2 `[Status, boolean]` tuple; the multi-permission `MultiResult` shape is unchanged. Under v3 `mapResult` took the MultiResult branch for a plain status string, found none of the media permission keys on it, and returned `authorized: true` regardless of what the user chose. BREAKING CHANGE: `AuthorizationResult.details` is now `MultiResult | Status` rather than `MultiResult | Result`, and perms v3 is required. Apps pinning perms v2 must upgrade alongside this release. Co-Authored-By: Claude Opus 5 (1M context) --- packages/imagepicker/common.ts | 11 +++++------ packages/imagepicker/package.json | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/imagepicker/common.ts b/packages/imagepicker/common.ts index a6c55761..2b51c9b1 100644 --- a/packages/imagepicker/common.ts +++ b/packages/imagepicker/common.ts @@ -1,5 +1,5 @@ import { ImageAsset, ImageSource } from '@nativescript/core'; -import { MultiResult, Result } from '@nativescript-community/perms'; +import { MultiResult, Status } from '@nativescript-community/perms'; export enum ImagePickerMediaType { Any = 0, @@ -148,18 +148,17 @@ export interface ImagePickerApi { export interface AuthorizationResult { authorized: boolean; - details: MultiResult | Result; + details: MultiResult | Status; } const requestingPermissions = ['android.permission.READ_MEDIA_IMAGES', 'android.permission.READ_MEDIA_VIDEO']; export abstract class ImagePickerBase implements ImagePickerApi { abstract authorize(): Promise; abstract present(): Promise; - protected mapResult(result: MultiResult | Result): AuthorizationResult { + protected mapResult(result: MultiResult | Status): AuthorizationResult { let authorized = true; - if (Array.isArray(result) && result.length == 2) { - // is of type Result - authorized = result[0] === 'authorized' || result[0] === 'limited'; + if (typeof result === 'string') { + authorized = result === 'authorized' || result === 'limited'; } else { const t = result as MultiResult; requestingPermissions.forEach((permission) => { diff --git a/packages/imagepicker/package.json b/packages/imagepicker/package.json index 34f694f6..4d570eff 100644 --- a/packages/imagepicker/package.json +++ b/packages/imagepicker/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" } }