Skip to content

Commit

Permalink
feat: Removal of WRITE_EXTERNAL_STORAGE permission (#939)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: removed WRITE_EXTERNAL_STORAGE permission from module AndroidManifest file

* #936 - removed WRITE_EXTERNAL_STORAGE permission from module AndroidManifest file

* #936 - updated documentation website with WRITE_EXTERNAL_STORAGE migration notes

* #936 - added additional Android 11 permission documentation

Co-authored-by: Mateus Andrade <mateus.andrade47@outlook.com>
  • Loading branch information
ryanbourneuk and MateusAndrade committed Dec 23, 2020
1 parent 5f3bc4f commit 98b1903
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 3 deletions.
2 changes: 0 additions & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cl.json">

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

<application>
<provider
android:name=".RNShareFileProvider"
Expand Down
3 changes: 3 additions & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

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

<!-- required for react-native-share base64 sharing -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:name=".MainApplication"
android:label="@string/app_name"
Expand Down
9 changes: 9 additions & 0 deletions website/docs/installing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ Also, to use this library on iOS you will need:

After that, you will see that the library is now available at your `node_modules`.

**Note:** If your application requires the ability to share `base64` files on Android, you need to add

```xml
<!-- required for react-native-share base64 sharing -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
```

to your application's `AndroidManifest.xml` file as per the example project.

## Manual Linking

If the auto-linking doesn't work for any reason, you can still run a:
Expand Down
27 changes: 27 additions & 0 deletions website/docs/migrate-v4-to-v5.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
id: migrate-v4-to-v5
title: Migrating to v5
---

## iOS

No breaking changes :relieved:

## Android

[v5 introduces a change](https://github.com/react-native-community/react-native-share/issues/936) to remove the `WRITE_EXTERNAL_STORAGE` permission from being automatically added to implementing apps.

This is motivated by the Android 11 system enforcing new restrictions on storage, and mandating the use of scoped storage. If this impacts you, you should read more here to make sure your app will still work on Android 11: [Scoped Storage restrictions](https://developer.android.com/about/versions/11/privacy/storage)

### Removal of WRITE_EXTERNAL_STORAGE permission request

`base64` file sharing requires the `WRITE_EXTERNAL_STORAGE` permission to be included in the AndroidManifest.xml file. As `WRITE_EXTERNAL_STORAGE` is seen as a [dangerous](https://developer.android.com/reference/android/Manifest.permission#WRITE_EXTERNAL_STORAGE) permission, it is now the responsibility of the implementing app to add this permission to their own AndroidManifest.xml file.

To do this, add:

```xml
<!-- required for react-native-share base64 sharing -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
```

to your application's `AndroidManifest.xml` file as per the example project.
9 changes: 9 additions & 0 deletions website/docs/share-open.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ When sharing a `base64` file, you will need to follow the format below:

```url: "data:<data_type>/<file_extension>;base64,<base64_data>"```

**Note:** If your application requires the ability to share `base64` files on Android, you need to add

```xml
<!-- required for react-native-share base64 sharing -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
```

to your application's `AndroidManifest.xml` file as per the example project.

## Sharing a file directly

When sharing a local file directly, you can use the following format:
Expand Down
2 changes: 1 addition & 1 deletion website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
'testing',
],
Recipes: ['share-remote-file'],
Migrating: ['migrate-v3-to-v4'],
Migrating: ['migrate-v3-to-v4', 'migrate-v4-to-v5'],
Troubleshooting: ['troubleshooting-ios'],
},
};

0 comments on commit 98b1903

Please sign in to comment.