Comments (5)
These are only deprecated for now, and based on the distribution of Android versions and on how long these permissions have been around, it will likely be many years until they're removed. We support the current system for newer versions of Android. If things change, we will be sure to update the plugin as needed.
from media.
Hi @nkalupahana, I think this issue should be reopened.
I explain why:
Here
public void getAlbums(PluginCall call) {
Log.d("DEBUG LOG", "GET ALBUMS");
if (isStoragePermissionGranted()) {
Log.d("DEBUG LOG", "HAS PERMISSION");
_getAlbums(call);
} else {
Log.d("DEBUG LOG", "NOT ALLOWED");
this.bridge.saveCall(call);
requestAllPermissions(call, "permissionCallback");
}
}
isStoragePermissionGranted()
is checking only for permissions related to the current SDK
@Permission(
strings = { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE },
alias = "publicStorage"
),
@Permission(
strings = { Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_MEDIA_VIDEO },
alias = "publicStorage13Plus"
)
I don't see the point of 'requestAllPermissions' if isStoragePermissionGranted
== false.
If I'm targeting SDK 33, in my manifest I need to set android:maxSdkVersion="32"
for android.permission.READ_EXTERNAL_STORAGE
and android.permission.WRITE_EXTERNAL_STORAGE
this means that those permissions are available only if the device is running SDK <= 32
If I'm running on SDK 33:
- those permissions are not present
- you are properly not checking for them in the
isStoragePermissionGranted
- but if the proper permissions are not yet granted, you are requesting for all, including those not required
The problem is that in described case:
- the first time I invoke
getAlbums
, after the user granted access permissions, I get an error for missing (not needed) permissions.
{nativeError: Error: Missing the following permissions in AndroidManifest.xml:
android.permission.READ_EXTERNAL_STORAGE ...
- If I retry (the user already granted) it works without problem
Is it possible to replace requestAllPermissions
with requestPermissionForAlias
and request only permissionSet (alias) related to the current SDK?
from media.
@nkalupahana @davideramoaxa look i what i did in capacitor-video-player i use requestPermissionForAlias and that the only i found to make it working
from media.
@davideramoaxa I'm sorry, but I'm unable to reproduce the error you're talking about. Using the example app on an API 33 emulator, I (1) opened it, (2) clicked "Get Albums", and (3) Clicked "Allow" on the permissions prompt, and the albums on the device showed up (no need to retry). Could you provide some sort of reproduction with the example app, or let me know what needs to be modified on the example app to cause this issue? Thanks!
from media.
@davideramoaxa please provide a reproduction with a separate app or the example app! Otherwise, I'll be closing this issue as failed to reproduce.
from media.
Related Issues (20)
- 199131008-c2327514-8987-4535-b377-41dbed6a8e52.png (1302×540)https://github.com/orgs/community/discussions/35791
- Type in your language with Gboard
- Error while copying media file HOT 10
- Media.savePhoto's Promise<PhotoResponse> returns 'undefined' on iOS HOT 2
- Read file path from platform-specific identifier on iOS HOT 1
- docs(android): make it clear that file return on savePhoto is only available on Android
- App crash after downloading an image HOT 8
- App is crashed on Android due to EACCES (Permission denied) HOT 11
- Is there any method to retrieve more photos like using offset in query? HOT 1
- feat(android): add getAlbumsPath() function to get where albums are stored on filesystem
- Error: RuntimeException occurred : In SaveVideo method HOT 1
- RuntimeException occurred / EACCES (Permission denied) when trying to save a photo/gif/video on android < 13 HOT 12
- When wanting to save photo to Album with identifier, getting identifier doesnt exist even tho Album exist HOT 3
- feat(ios): support jpeg files instead of png HOT 3
- Camera plugin is not implement on Android (Capacitor Camera) when pairing with Capacitor-Community/Media HOT 2
- savePhoto is not working in android 8.1.0 Samsung SM-T580 tablet HOT 1
- MediaFetchOptions support individual photo for high resolution HOT 2
- feat(ios): get specific media by identifier HOT 9
- feat: has access right / error codes for all errors HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from media.