Files
react-native/website/versioned_docs/version-0.48/autogen_CameraRoll.md
T
2017-10-04 17:02:20 -07:00

16 lines
4.7 KiB
Markdown

---
id: version-0.48-cameraroll
title: CameraRoll
category: APIs
permalink: docs/cameraroll.html
original_id: cameraroll
---
<div><div><p><code>CameraRoll</code> provides access to the local camera roll / gallery.
Before using this you must link the <code>RCTCameraRoll</code> library.
You can refer to <a href="docs/linking-libraries-ios.html" target="_blank">Linking</a> for help.</p><h3><a class="anchor" name="permissions"></a>Permissions <a class="hash-link" href="docs/cameraroll.html#permissions">#</a></h3><p>The user's permission is required in order to access the Camera Roll on devices running iOS 10 or later.
Add the <code>NSPhotoLibraryUsageDescription</code> key in your <code>Info.plist</code> with a string that describes how your
app will use this data. This key will appear as <code>Privacy - Photo Library Usage Description</code> in Xcode.</p></div><span><h3><a class="anchor" name="methods"></a>Methods <a class="hash-link" href="docs/cameraroll.html#methods">#</a></h3><div class="props"><div class="prop"><h4 class="methodTitle"><a class="anchor" name=""></a>=<span class="methodType">(;, AssetTypeOptions, static, (, :)</span> <a class="hash-link" href="docs/cameraroll.html#">#</a></h4></div><div class="prop"><h4 class="methodTitle"><a class="anchor" name="savetocameraroll"></a><span class="methodType">static </span>saveToCameraRoll<span class="methodType">(tag, type?)</span> <a class="hash-link" href="docs/cameraroll.html#savetocameraroll">#</a></h4><div><p>Saves the photo or video to the camera roll / gallery.</p><p>On Android, the tag must be a local image or video URI, such as <code>"file:///sdcard/img.png"</code>.</p><p>On iOS, the tag can be any image URI (including local, remote asset-library and base64 data URIs)
or a local video file URI (remote or data URIs are not supported for saving video at this time).</p><p>If the tag has a file extension of .mov or .mp4, it will be inferred as a video. Otherwise
it will be treated as a photo. To override the automatic choice, you can pass an optional
<code>type</code> parameter that must be one of 'photo' or 'video'.</p><p>Returns a Promise which will resolve with the new URI.</p></div></div><div class="prop"><h4 class="methodTitle"><a class="anchor" name="getphotos"></a><span class="methodType">static </span>getPhotos<span class="methodType">(params)</span> <a class="hash-link" href="docs/cameraroll.html#getphotos">#</a></h4><div><p>Returns a Promise with photo identifier objects from the local camera
roll of the device matching shape defined by <code>getPhotosReturnChecker</code>.</p><p>Expects a params object of the following shape:</p><ul><li><code>first</code> : {number} : The number of photos wanted in reverse order of the photo application (i.e. most recent first for SavedPhotos).</li><li><code>after</code> : {string} : A cursor that matches <code>page_info { end_cursor }</code> returned from a previous call to <code>getPhotos</code>.</li><li><code>groupTypes</code> : {string} : Specifies which group types to filter the results to. Valid values are:<ul><li><code>Album</code></li><li><code>All</code></li><li><code>Event</code></li><li><code>Faces</code></li><li><code>Library</code></li><li><code>PhotoStream</code></li><li><code>SavedPhotos</code> // default</li></ul></li><li><code>groupName</code> : {string} : Specifies filter on group names, like 'Recent Photos' or custom album titles.</li><li><code>assetType</code> : {string} : Specifies filter on asset type. Valid values are:<ul><li><code>All</code></li><li><code>Videos</code></li><li><code>Photos</code> // default</li></ul></li><li><code>mimeTypes</code> : {string} : Filter by mimetype (e.g. image/jpeg).</li></ul><p>Returns a Promise which when resolved will be of the following shape:</p><ul><li><code>edges</code> : {Array&lt;node&gt;} An array of node objects<ul><li><code>node</code>: {object} An object with the following shape:<ul><li><code>type</code>: {string}</li><li><code>group_name</code>: {string}</li><li><code>image</code>: {object} : An object with the following shape:<ul><li><code>uri</code>: {string}</li><li><code>height</code>: {number}</li><li><code>width</code>: {number}</li><li><code>isStored</code>: {boolean}</li></ul></li><li><code>timestamp</code>: {number}</li><li><code>location</code>: {object} : An object with the following shape:<ul><li><code>latitude</code>: {number}</li><li><code>longitude</code>: {number}</li><li><code>altitude</code>: {number}</li><li><code>heading</code>: {number}</li><li><code>speed</code>: {number}</li></ul></li></ul></li></ul></li><li><code>page_info</code> : {object} : An object with the following shape:<ul><li><code>has_next_page</code>: {boolean}</li><li><code>start_cursor</code>: {boolean}</li><li><code>end_cursor</code>: {boolean}</li></ul></li></ul></div></div></div></span></div>