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

feat(android): adjust Android 13 requestPhotoGalleryPermissions #13750

Merged
merged 4 commits into from
Feb 21, 2023

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Feb 18, 2023

  • quick info about granular media permissions for Android 13+
  • adjust requestPhotoGalleryPermissions() and hasPhotoGalleryPermissions()

Test

const window = Ti.UI.createWindow({});
window.addEventListener("click", function() {
	console.log("has permission: " + Ti.Media.hasPhotoGalleryPermissions());

	Ti.Media.requestPhotoGalleryPermissions(function(e) {
		console.log("Success: " + e.success);
		if (e.success) {
			Ti.Media.openPhotoGallery({});
		}
	})
})
window.open();

open the app and click in the window. It should display the permission check and after that the photo gallery. Second click just the photo gallery.

Add

<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>

in your tiapp.xml into <manifest>

@m1ga m1ga changed the title docs: info about Android 13 media permissions feat(android): adjust Android 13 requestPhotoGalleryPermissions Feb 18, 2023
@hansemannn hansemannn merged commit 3b7ec5c into master Feb 21, 2023
@m1ga m1ga deleted the 230218_Android_permission branch February 22, 2023 07:53
@francesco-lombardo
Copy link

francesco-lombardo commented Apr 7, 2023

It seems that Ti.Media.requestPhotoGalleryPermissions fails on Android 12, contrary to Ti.Media.openPhotoGallery that successfully open the gallery (on the same device, with the same permissions).

@m1ga
Copy link
Contributor Author

m1ga commented Apr 7, 2023

Oh, I've mixed up the SDK level! It should be 33 not 31, will adjust that. Give me a sec, I'll upload a new build so you can test

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.

3 participants