Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I ask the user to enable the MANAGE_EXTERNAL_STORAGE permission in React Native?

Android 11 is more restrictive than older versions when providing access to user files.

The goal is to improve security, and that is ok, but it breaks some apps.

To fix that, we can add <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> to the app manifest. That allows the user to go to the app settings and turn on the option (allow management of all files):

enter image description here

But this is not enough by itself, as users won't do that if they are not asked for it. They will only see an app that does not work.

At this moment, there is literally no mention to this particular permission on the React Native repository.

Is there any solution to this? We should be able to check whether that permission has been given so we can act accordingly, and we should be able to ask the user to grant the permission.

like image 798
Josu Goñi Avatar asked Oct 24 '25 03:10

Josu Goñi


1 Answers

you can use this library: https://www.npmjs.com/package/manage-external-storage

// check if can manage
checkManagePermission().then((isManagePermitted) => {
  console.log(isManagePermitted);
});

// request rights to manage
requestManagePermission().then((isManagePermitted) => {
  console.log(isManagePermitted);
});
like image 143
Fedechka Avatar answered Oct 25 '25 18:10

Fedechka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!