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

@capacitor/camera - Android "Selected Photos Access" #2150

Open
julienkermarec opened this issue Jul 11, 2024 · 2 comments
Open

@capacitor/camera - Android "Selected Photos Access" #2150

julienkermarec opened this issue Jul 11, 2024 · 2 comments
Labels
platform: android type: feature request A new feature, enhancement, or improvement

Comments

@julienkermarec
Copy link

Feature Request

Plugin

@capacitor/camera

Description

Android 14 introduces Selected Photos Access, which allows users to grant apps access to specific images and videos in their library, rather than granting access to all media of a given type.

Capture d’écran 2024-07-11 à 11 05 11

This change is only enabled if your app targets Android 14 (API level 34) or higher. If you don't use the photo picker yet, we recommend implementing it in your app to provide a consistent experience for selecting images and videos that also enhances user privacy without having to request any storage permissions.

If you maintain your own gallery picker using storage permissions and need to maintain full control over your implementation, adapt your implementation to use the new READ_MEDIA_VISUAL_USER_SELECTED permission. If your app doesn't use the new permission, the system runs your app in a compatibility mode.

Platform(s)

Android

Preferred Solution

Implement the new way to request permission & picture selection

Alternatives

No other plugins alternative

Additional Context

New Permission to add

<!-- To handle the reselection within the app on devices running Android 14 or higher if your app targets Android 14 (API level 34) or higher.  -->
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />

New requesting permission :

// Register ActivityResult handler
val requestPermissions = registerForActivityResult(RequestMultiplePermissions()) { results ->
    // Handle permission requests results
    // See the permission example in the Android platform samples: https://github.com/android/platform-samples
}

// Permission request logic
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
    requestPermissions.launch(arrayOf(READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, READ_MEDIA_VISUAL_USER_SELECTED))
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
    requestPermissions.launch(arrayOf(READ_MEDIA_IMAGES, READ_MEDIA_VIDEO))
} else {
    requestPermissions.launch(arrayOf(READ_EXTERNAL_STORAGE))
}

@ionitron-bot ionitron-bot bot added the triage label Jul 11, 2024
@ionitron-bot ionitron-bot bot removed the triage label Jul 11, 2024
@alexgerardojacinto alexgerardojacinto added the type: feature request A new feature, enhancement, or improvement label Aug 19, 2024
@M13CZ
Copy link

M13CZ commented Aug 30, 2024

Is there aby workaround for this before it will be fixed on plugin side?

@julienkermarec
Copy link
Author

Is there aby workaround for this before it will be fixed on plugin side?

Yes, on can use @capacitor/filesystem for selecting private photo

For using camera, you need to continue using @capacitor/camera

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: android type: feature request A new feature, enhancement, or improvement
Projects
None yet
Development

No branches or pull requests

4 participants