Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5744] iOS: Requesting permissions to open gallery will not allow gallery to open.

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionCannot Reproduce
Resolution Date2018-05-21T09:01:05.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsios
ReporterJoshua A. Ceaser
AssigneeShak Hossain
Created2018-05-20T22:46:05.000+0000
Updated2018-05-21T14:33:40.000+0000

Description

When requesting gallery permissions, after accepting permissions the gallery does not open. Steps to reproduce: 1. Create a sample application 2. Update the index.js with the attached 3. Update the alloy.js with the attached to force splashscreen as snapshot. 4. Update the tiapp.xml with the NSPhotoLibraryUsageDescription and NSPhotoLibraryAddUsageDescription key in the attached tiapp.xml 5. Run the application and click on "Hello World" 6. Accept permissions 7. Notice nothing happens. index.js
var win = Ti.UI.createWindow({
    backgroundColor: '#fff'
});
 
function doClick(e) {
	var _galleryOptions = {
		allowEditing : false,
		allowMultiple : false,
		autohide : true,
		mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
	};

	if (Ti.Media.hasPhotoGalleryPermissions()) {
		Ti.Media.openPhotoGallery(_galleryOptions);
	} else {
		Ti.Media.requestPhotoGalleryPermissions(function(_evt) {
			if (_evt.success) {
				Ti.Media.openPhotoGallery(_galleryOptions);
			} else {
				alert('We need gallery permissions');
			}
		});
	}
}
 
 
var btn = Ti.UI.createButton({
    title: 'Trigger'
});
 
btn.addEventListener('click', doClick);
 
win.add(btn);
 
win.open();
tiapp.xml
<key>NSPhotoLibraryUsageDescription</key>
                <string>To allow you to upload photos of documents</string>
                <key>NSPhotoLibraryAddUsageDescription</key>
                <string>To allow you to upload photos of documents</string>
alloy.js
Ti.App.forceSplashAsSnapshot = true

Comments

  1. Hans Knöchel 2018-05-21

    Works fine here (both with main- and kroll-thread). Try to reinstall your app or reach out to the community via Slack or Stackoverflow for more questions.
  2. Joshua A. Ceaser 2018-05-21

    I left out the forceSplashAsSnapshot must be set to true.
  3. Hans Knöchel 2018-05-21

    Thats a very important detail, hehe. In that case, it is a duplicate of TIMOB-26047 which already has a fix in place that you can use today. Cheers!

JSON Source