These are chat archives for lwansbrough/react-native-camera

5th
Feb 2016
Bernardo Avancena
@ardowz
Feb 05 2016 00:25
it appears that using the <Camera> returns an object not a string..
Bernardo Avancena
@ardowz
Feb 05 2016 00:31
So my issue was i was using var Camera = require('react-native-camera'); vs import Camera from 'react-native-camera'; which does work. the constants work now with that kind of import
Bernardo Avancena
@ardowz
Feb 05 2016 01:42
@GedoonS What did you do to solve the preview? My preview doesn't work, it just gives me a red screen
Zack Story
@rt2zz
Feb 05 2016 01:55
@ardowz try this: lwansbrough/react-native-camera#176
Bernardo Avancena
@ardowz
Feb 05 2016 05:41
thanks, that works. now its just the capture
Kimmo Laine
@GedoonS
Feb 05 2016 08:38
https://github.com/exponentjs/react-native-image-picker-android here's a different camera component that I've had some success with. I'll try my luck with it first. If that one doesn't work either, I'll come back to this.
Kimmo Laine
@GedoonS
Feb 05 2016 10:15
Okay so I was able to do a basic functioning Android camera application with react-native-image-picker-android. I recommend you check it out for reference: https://github.com/exponentjs/react-native-image-picker-android
Christopher Dro
@christopherdro
Feb 05 2016 19:18
For starters the Api is different between iOS and Android on image capture
your returning a promise with Android
Bernardo Avancena
@ardowz
Feb 05 2016 19:20
for the capture?
Christopher Dro
@christopherdro
Feb 05 2016 19:20
ye
yea*
ones async ones not
this is where capture fails for me
Camera camera = RCTCamera.getInstance().acquireCameraInstance(options.getInt(“type"));
i got preview in android 5
but no go on 4.4.2
Bernardo Avancena
@ardowz
Feb 05 2016 19:21
this is the code I'm using for both and only works for iOS:
_takePicture() {
    this.camera.capture()
      .then((data) => {
        var currentImagesList = this.state.capturedImages;

        var newCapturedImage = {
          path : data,
        };
        //console.log(newCapturedImage);
        currentImagesList.push(newCapturedImage);
        this.setState({
          capturedImages: currentImagesList,
        });


      })
      .catch(err => console.error(err));
  }
Christopher Dro
@christopherdro
Feb 05 2016 19:26
@ardowz Nevermind
lwansbrough/react-native-camera@45c2686
this commit converted both platforms to promises
Bernardo Avancena
@ardowz
Feb 05 2016 19:36
oh
the error I'm getting is couldn't find key type in dynamic object.
whenever i try capture
Bernardo Avancena
@ardowz
Feb 05 2016 19:47
the error you mentioned is the one I'm getting too
Kimmo Laine
@GedoonS
Feb 05 2016 20:38
"couldn't find key type in dynamic object" yeah that was missing from the code example, but if you add it in the props, it'll work. I edited my local copy of the camera.js to use ...defaultProps to complete the options in capture(). But you can just as well add type: Camera.constants.Type.back prop to your <Camera>
Bernardo Avancena
@ardowz
Feb 05 2016 21:01
i did have the type in the props.
<Camera
            ref={(cam) => {
              this.camera = cam;
            }}
            style={styles.container}
            onBarCodeRead={this._onBarCodeRead}
            type={Camera.constants.Type.back}
            captureTarget={Camera.constants.CaptureTarget.disk}
            captureMode={Camera.constants.CaptureMode.still}
            flashMode={Camera.constants.FlashMode.auto}
            orientation={Camera.constants.Orientation.portrait}
          ></Camera>
Bernardo Avancena
@ardowz
Feb 05 2016 21:47

So for me to get it to work i changed the line

`Camera camera = RCTCamera.getInstance().acquireCameraInstance(options.getInt(“type"));`

to

Camera camera = RCTCamera.getInstance().acquireCameraInstance(2);
`
its not the correct approach, but the type seems like its not being passed properly
Christopher Dro
@christopherdro
Feb 05 2016 21:47
ya there your forcing either front or back
not sure what the constant is set to
public static final int RCT_CAMERA_TYPE_BACK = 2;
constants are not being passed properly for some reason
Bernardo Avancena
@ardowz
Feb 05 2016 21:51
yeah ill just force that in for now, since i don't need it mine to be switching anyway