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

iOS: Ti.Media.openPhotoGallery does not respect Selected Photos permission #13277

Open
1 task done
phillipmovista opened this issue Feb 21, 2022 · 7 comments
Open
1 task done
Labels
bug ios needs triage This issue hasn't been reviewed by maintainers

Comments

@phillipmovista
Copy link

I have searched and made sure there are no existing issues for the issue I am filing

  • I have searched the existing issues

Description

When we use Ti.Media.openPhotoGallery for selecting photos in our application, after selecting iOS Photo Permissions to only allow access to "selected photos", the openPhotoGallery function still gives the app access to all photos.

Expected Behavior

After our code calls Ti.Media.openPhotoGallery like https://docs.axway.com/bundle/Titanium_SDK_allOS_en/page/camera_and_photo_gallery_apis.html#CameraandPhotoGalleryAPIs-Gallery, we do get a popup allowing us to select the photo permission and after that, a gallery pops up.

If I use the Selected Photos option, I can see later in Settings that the limited number of photos are showing they are accessible, but the app still allows all photos.

Details from iOS and this new security is: https://developer.apple.com/documentation/photokit/delivering_an_enhanced_privacy_experience_in_your_photos_app

Actual behavior

This shows the permissions in Settings about which photos should be available:
Screen Shot 2022-02-21 at 12 22 54 PM

When I then go into the app and run the code that does Ti.Media.openPhotoGallery I see these photos as options to select:
Screen Shot 2022-02-21 at 12 23 08 PM

I would expect to see only the 3 photos I gave permission to.

Reproducible sample

We have some other code around this for the callbacks (which work as expected) but this is the code with some extra console statements to show how we are opening this option.

Ti.Media.openPhotoGallery({
	success: (e) => {
		for (var i = 0; i < e.images.length; i++) {
			console.error(e.images[i]);

			selectedItems.push({
				media: e.images[i].media
			});
		}
		done();
	},
	cancel: () => {
		cancel();
	},
	error: (error) => {
		console.error('Photo gallery error: ', error);
		cancel();
	},
	autohide: true,
	allowEditing: false,
	allowMultiple: true,
	selectionLimit: args.max,
	mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO]
});

Steps to reproduce

In our case, the reproduction is that once the dialog box opens the first time asking which photo permissions to use, choose "Selected Photos" and just select a few photos. You can then verify that inside Settings to show it is only allowing access to some photos.

In the application, you should see all photos available.

Platform

iOS

SDK version you are using

10.1.1.GA

@phillipmovista phillipmovista added bug needs triage This issue hasn't been reviewed by maintainers labels Feb 21, 2022
@phillipmovista
Copy link
Author

I am going to see about using ti.imagepicker for now (https://github.com/hansemannn/titanium-imagepicker) because it does seem to handle the permissions properly.

@hansemannn
Copy link
Collaborator

The reason why it shows all photos is because of the PHPickerViewController being used on iOS 13+, which is a sandbox-based API that does not share the photos with the app unless selected. Therefore, it's at least not that critical. It would be interesting to know what exactly you would expect instead.

@phillipmovista
Copy link
Author

Sorry if I am not understanding the reply. I tested the ti.imagepicker and saw that it DOES do what I expect, which Ti.Media.openPhotoGallery does not.

If I select that the app only has permission to a few photos and then Ti.Media.openPhotoGallery runs, I would expect the photo gallery that opens would only be showing those photos I gave permission to - not all photos as I see it listed now.

Since iOS is set up in a way to allow the permission at a photo by photo level, it does feel important for Ti.Media.openPhotoGallery to respect those permissions.

Let me know if there is a different way to explain what I am seeing.

@hansemannn
Copy link
Collaborator

Yep, the reason for that is that the ti.imagepicker creates a custom UI (using the YPImagePicker library), while Ti.Media.openPhotoGallery uses the native PHPickerViewController class (system iOS class) directly. Thats where the difference comes from. If you want only the ones that you selected, either use [allowMultiple: 1](https://titaniumsdk.com/api/structs/photogalleryoptionstype.html#allowMultiple) (which will use the "old" dialog that only returns granted photos, or use the ti.imagepicker UI with a custom UI. That's basically what's possible natively.

@phillipmovista
Copy link
Author

Thank you. I am using the ti.imagepicker now, but even with [allowMultiple: 1] option, I still found it was returning me more than the ones with permission for the app to select. To me that seems like a bug in the Ti.Media layer. Is that right?

@hansemannn
Copy link
Collaborator

Sorry, I mean allowMultiple: false. But happy it works with ti.imagepicker for now!

@phillipmovista
Copy link
Author

Oh, so if we need a way to select multiple at a time, we should go with ti.imagepicker and if we use openPhotoGallery, it only will respect the OS permissions 100% with 1 photo at a time?

My recommendation would still be to treat this as a bug since that is hard to see happening and I would think the expectation is always to follow the OS permissions.

@m1ga m1ga added the ios label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ios needs triage This issue hasn't been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

3 participants