react-native icon indicating copy to clipboard operation
react-native copied to clipboard

CameraRoll / Cannot read property 'getPhotos' of undefined

Open klausbreyer opened this issue 11 years ago • 8 comments

Hi there,

I wanted to use the CameraRoll. But it does not work.

   CameraRoll.getPhotos({first: 2,}, 
            function(data) { // richtiger callback
            console.log(data);
        }, function(err) { // error callback
            console.log(err);
        });

this is my header:

'use strict';

var React = require('react-native');
var {
  AppRegistry,
  View,
  Animated,
  StatusBarIOS,
  CameraRoll,
  TouchableOpacity,
  TouchableWithoutFeedback,
  Text,
  StyleSheet,
  NavigatorIOS
} = React;

are there any more requirements I possibly missed?

"react-native": "^0.13.2",

klausbreyer avatar Nov 06 '15 12:11 klausbreyer

For Android: #3901 For iOS: You need to link the libraries in XCode.

alexkrolick avatar Nov 06 '15 16:11 alexkrolick

@klausbreyer

https://thebhwgroup.com/blog/accessing-iphone-camera-roll-images-react-native

I followed this tutorial on how to use Camera Roll. I've only tried it on iOS. I'm not certain that Android works the same

JakeRawr avatar Nov 06 '15 18:11 JakeRawr

@whokilledtheelectricmonk, @JakeRawr thanks for answering!

ide avatar Nov 06 '15 19:11 ide

More info on linking the lib: You have to import node_modules/react-native/Libraries/CameraRoll/RCTCameraRoll.xcodeproj

CarlosLCervantes avatar Jun 24 '16 23:06 CarlosLCervantes

FWIW, https://facebook.github.io/react-native/docs/linking-libraries-ios.html – Manual Step 2.

image

adamkdean avatar Aug 26 '16 00:08 adamkdean

For those running into problems after correctly linking the libRCTCameraRoll.a library, don't forget to correctly set NSPhotoLibraryUsageDescription in Info.plist.

zk avatar Nov 20 '16 19:11 zk

I followed the instructions here: https://facebook.github.io/react-native/docs/linking-libraries-ios.html

If I add libRCTCameraRoll.a it puts out an error saying that

Unable to run command 'Libtool libRCTCameraRoll.a' - this target might include its own product.

Can anyone point out what I'm missing?

paulsoh avatar Apr 29 '17 20:04 paulsoh

Hi @paulsoh did you find the solution to this?

lmadigan avatar Apr 28 '18 14:04 lmadigan