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"; }; /**