Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(camera): Handle 'Limited' iOS Photo permission. #600

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

boutier
Copy link
Contributor

@boutier boutier commented Sep 17, 2024

Limited means "we have access to some photos and you can save photos from the application".

Thus, when we give a limited access to the gallery:

  • succeed
  • save to gallery

In this patch, also add code to check that the switch is exhaustive, such that compilation will fail and we won't forget to handle future cases.

Limited means "we have access to some photos and you can save photos
from the application".

Thus, when we give a limited access to the gallery:
  - succeed
  - save to gallery

In this patch, also add code to check that the switch is exhaustive,
such that compilation will fail and we won't forget to handle future
cases.
Copy link
Contributor

@jcassidyav jcassidyav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, but I would prefer if we did not hide the fact that photo permissions were not available, as camera permissions are available for request separately in the scenario where they are not required.

packages/camera/index.ios.ts Show resolved Hide resolved
requestPhotosPermissions().then(() => {
requestCameraPermissions().then(resolve, reject);
}, reject);
// Even if we don't have photo access we may want to get camera access.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with ignoring the failure to get photo permissions, if the user does not want photo permissions ( because they are not saving to the gallery) they do not have to call this method, ignoring the failure removes the ability to inform the user, possibly directing them to enable permissions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. But:

  • I don't like to have a result that relies on the internal implementation (requesting first photos or first permissions)
  • I don't like to have a failure without knowing which permission was faulty

So, do we want to have something like @nativescript-community/perms that would return a Promise<MultiResult>.

Or something simpler returning just a boolean (granted or not)

requestCameraPermissions(): Promise<0 | 1>
requestPhotosPermissions(): Promise<0 | 2>
requestPermissions(): Promise<number>
enum TypeFlags {
    Camera = 1,
    Photo = 2,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants