Description
When calling openPhotoGallery and passing in
mediaTypes: [ Ti.Media.MEDIA_TYPE_PHOTO ]
, a mediaType of
Ti.Media.MEDIA_TYPE_LIVEPHOTO
can be returned and the shape of the returned object is also different, containing a
livePhotos
array, instead of a
images
array
const win = Ti.UI.createWindow({ layout: 'vertical' });
const singleBtn = Ti.UI.createButton({ title: 'Select single', top: 50 });
singleBtn.addEventListener('click', () => {
selectImage(false);
});
win.add(singleBtn);
const multiBtn = Ti.UI.createButton({ title: 'Select multiple' });
multiBtn.addEventListener('click', () => {
selectImage(true);
});
win.add(multiBtn);
win.open();
function selectImage(allowMultiple) {
Ti.Media.requestPhotoGalleryPermissions((e) => {
if (!e.success) {
console.error('failed to get permissions');
console.error(e);
return;
}
Titanium.Media.openPhotoGallery({
success: function(e) {
console.log(e);
},
error: function(e) {
console.error('errored on openPhotoGallery')
console.error(e);
},
mediaTypes: [ Ti.Media.MEDIA_TYPE_PHOTO ],
allowMultiple
});
});
}
Steps to reproduce
1. Add the above code to an existing app.js
2. Ensure you have a NSPhotoLibraryUsageDescription key in your plist like below
<key>NSPhotoLibraryUsageDescription</key>
<string>Can we steal your pics?</string>
3. Build to iOS
4. Tap the
Select single
button and select a live photo
5. Tap the
Select multi
button and select a live photo
Actual
In step 4 an object is returned with mediaType of Ti.Media.MEDIA_TYPE_PHOTO
In step 5 an object is returned with a livePhotos array and contains an object with a media type of Ti.Media.MEDIA_TYPE_LIVEPHOTO
Expected
A mediaType of Ti.Media.MEDIA_TYPE_LIVEPHOTO should not be returned if only Ti.Media.MEDIA_TYPE_PHOTO was requested
It looks like we use a different type of picker dependent on whether allowMultiple is set, so it might be that this is down to a difference there. However it feels strange to me for us to return a live photo when one was not requested?
PR - https://github.com/appcelerator/titanium_mobile/pull/12289 Test Case -
In Case of Photo media type selection it should show images only after selection.
FR Passed. Waiting for Jenkins build.