Skip to content

Commit

Permalink
fix: permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
mastro993 committed Jan 24, 2024
1 parent 7924986 commit 761919d
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions ts/utils/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@ export const requestIOPermission = async (
permission: RNPermissions.Permission,
rationale?: RNPermissions.Rationale
): Promise<boolean> => {
// 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";
};

/**
Expand All @@ -33,8 +27,13 @@ export const requestIOPermission = async (
export const checkIOPermission = async (
permission: RNPermissions.Permission
): Promise<boolean> => {
// 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";
};

/**
Expand Down

0 comments on commit 761919d

Please sign in to comment.