From 79249863999cdc0469e9725aff8280e144b7d196 Mon Sep 17 00:00:00 2001 From: Federico Mastrini Date: Wed, 24 Jan 2024 14:04:24 +0100 Subject: [PATCH 1/4] chore: remove media permissions prompt for iOS >= 17 --- ts/utils/permission.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ts/utils/permission.ts b/ts/utils/permission.ts index 098e301df12..19b3264598b 100644 --- a/ts/utils/permission.ts +++ b/ts/utils/permission.ts @@ -70,6 +70,9 @@ export const requestMediaPermission = async () => { : RNPermissions.PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE ); case "ios": + if (parseInt(Platform.Version, 10) >= 17) { + return true; + } return requestIOPermission(RNPermissions.PERMISSIONS.IOS.PHOTO_LIBRARY); default: return false; From 761919d57d8bd9c143981852e45623636c024b6f Mon Sep 17 00:00:00 2001 From: Federico Mastrini Date: Wed, 24 Jan 2024 17:00:09 +0100 Subject: [PATCH 2/4] fix: permissions --- ts/utils/permission.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ts/utils/permission.ts b/ts/utils/permission.ts index 19b3264598b..2f14c4fc71b 100644 --- a/ts/utils/permission.ts +++ b/ts/utils/permission.ts @@ -11,18 +11,12 @@ export const requestIOPermission = async ( permission: RNPermissions.Permission, rationale?: RNPermissions.Rationale ): Promise => { - // Be aware that some permissions may return "unavailable" event if the library - // documents them as supported. One notorious case is the iOS PHOTO_LIBRARY_ADD_ONLY - // permission. If such permission is automatically handled by the system upon request - // (such as PHOTO_LIBRARY_ADD_ONLY is), then you should not use this function to - // check nor to request such permission - const checkResult = await RNPermissions.check(permission); - if (checkResult === "granted") { + if (await checkIOPermission(permission)) { return true; } const requestStatus = await RNPermissions.request(permission, rationale); - return requestStatus === "granted"; + return requestStatus === "granted" || requestStatus === "limited"; }; /** @@ -33,8 +27,13 @@ export const requestIOPermission = async ( export const checkIOPermission = async ( permission: RNPermissions.Permission ): Promise => { + // Be aware that some permissions may return "unavailable" event if the library + // documents them as supported. One notorious case is the iOS PHOTO_LIBRARY_ADD_ONLY + // permission. If such permission is automatically handled by the system upon request + // (such as PHOTO_LIBRARY_ADD_ONLY is), then you should not use this function to + // check nor to request such permission const checkResult = await RNPermissions.check(permission); - return checkResult === "granted"; + return checkResult === "granted" || checkResult === "limited"; }; /** From cc11ea98f1204c3af265ffd48cfe83d230ba6f2d Mon Sep 17 00:00:00 2001 From: Federico Mastrini Date: Wed, 24 Jan 2024 17:44:57 +0100 Subject: [PATCH 3/4] chore: remove permission request on iOS --- ts/utils/permission.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ts/utils/permission.ts b/ts/utils/permission.ts index 2f14c4fc71b..6e3cb76ff53 100644 --- a/ts/utils/permission.ts +++ b/ts/utils/permission.ts @@ -16,7 +16,7 @@ export const requestIOPermission = async ( } const requestStatus = await RNPermissions.request(permission, rationale); - return requestStatus === "granted" || requestStatus === "limited"; + return requestStatus === "granted"; }; /** @@ -33,7 +33,7 @@ export const checkIOPermission = async ( // (such as PHOTO_LIBRARY_ADD_ONLY is), then you should not use this function to // check nor to request such permission const checkResult = await RNPermissions.check(permission); - return checkResult === "granted" || checkResult === "limited"; + return checkResult === "granted"; }; /** @@ -68,11 +68,6 @@ export const requestMediaPermission = async () => { ? RNPermissions.PERMISSIONS.ANDROID.READ_MEDIA_IMAGES : RNPermissions.PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE ); - case "ios": - if (parseInt(Platform.Version, 10) >= 17) { - return true; - } - return requestIOPermission(RNPermissions.PERMISSIONS.IOS.PHOTO_LIBRARY); default: return false; } From 6b421e63151882c79e9c64649882d6a5c0697490 Mon Sep 17 00:00:00 2001 From: Federico Mastrini Date: Wed, 24 Jan 2024 17:49:17 +0100 Subject: [PATCH 4/4] refactor: `requestIOPermission` --- ts/utils/permission.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ts/utils/permission.ts b/ts/utils/permission.ts index 6e3cb76ff53..3a14659338c 100644 --- a/ts/utils/permission.ts +++ b/ts/utils/permission.ts @@ -11,7 +11,8 @@ export const requestIOPermission = async ( permission: RNPermissions.Permission, rationale?: RNPermissions.Rationale ): Promise => { - if (await checkIOPermission(permission)) { + const checkResult = await checkIOPermission(permission); + if (checkResult) { return true; }