React Native Camera Roll
UPDATE:
As of react-native 0.19
, the CameraRoll module is now available on Android too!
Table of contents
Example
Checkout this example of a basic gallery app with infinite scroll:
https://github.com/bamlab/rn-camera-roll/tree/master/example
Setup
First, install the package:
npm install rn-camera-roll
Then, follow those instructions:
iOS
The Camera Roll iOS API is part of react-native
.
You have to import node_modules/react-native/Libraries/CameraRoll/RCTCameraRoll.xcodeproj
by following the libraries linking instructions.
Android
Update your gradle files
For react-native >= v0.15, this command will do it automatically:
react-native link rn-camera-roll
For react-native = v0.14 You will have to update them manually:
In android/settings.gradle
, add:
include ':rn-camera-roll'
project(':rn-camera-roll').projectDir = new File(settingsDir, '../node_modules/rn-camera-roll/android')
In android/app/build.gradle
add:
dependencies {
...
compile project(':rn-camera-roll')
}
MainActivity
Register the package into your // IMPORT HERE // ---
Usage
You can use the getPhotos
API as you would with the iOS API with the after
and the first
params.
You can use both the promise
syntax or the callback
syntax.
; { const photos = dataedges; console; /** On Android, this should log something like: [ { "uri": "file:/storage/emulated/0/DCIM/Camera/IMG_20160120_172426830.jpg", "width":3006, "height":5344, "orientation": 90 }, { "uri": "file:/storage/emulated/0/DCIM/Camera/IMG_20160116_153526816_TOP.jpg", "width": 5344, "height": 3006, "orientation": 0 } ... ] **/} { // Handle error here} { CameraRoll;}