UNPKG

2.33 kBMarkdownView Raw
1# expo-media-library
2
3Provides access to user's media library.
4
5# API documentation
6
7- [Documentation for the master branch](https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/sdk/media-library.md)
8- [Documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/media-library/)
9
10# Installation in managed Expo projects
11
12For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/media-library/).
13
14# Installation in bare React Native projects
15
16For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
17
18### Add the package to your npm dependencies
19
20```
21expo install expo-media-library
22```
23
24### Configure for iOS
25
26Add `NSPhotoLibraryUsageDescription`, and `NSPhotoLibraryAddUsageDescription` keys to your `Info.plist`:
27
28```xml
29<key>NSPhotoLibraryUsageDescription</key>
30<string>Give $(PRODUCT_NAME) permission to access your photos</string>
31<key>NSPhotoLibraryAddUsageDescription</key>
32<string>Give $(PRODUCT_NAME) permission to save photos</string>
33```
34
35Run `npx pod-install` after installing the npm package.
36
37### Configure for Android
38
39This package automatically adds the `READ_EXTERNAL_STORAGE` and `WRITE_EXTERNAL_STORAGE` permissions. They are used when accessing the user's images or videos.
40
41```xml
42<!-- Added permissions -->
43<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
44<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
45```
46
47Starting with Android 10, the concept of [scoped storage](https://developer.android.com/training/data-storage#scoped-storage) is introduced. Currently, to make `expo-media-library` working with that change, you have to add `android:requestLegacyExternalStorage="true"` to `AndroidManifest.xml`:
48
49```xml
50<manifest ... >
51 <application android:requestLegacyExternalStorage="true" ... >
52 ...
53 </application>
54</manifest>
55```
56
57# Contributing
58
59Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).