React-native-gifted-chat: How to add Camera button

Created on 20 Jul 2017  路  6Comments  路  Source: FaridSafi/react-native-gifted-chat

I want to use camera to send photos like other chat app does.

  • React Native version: 0.39.2
  • react-native-gifted-chat version: 0.0.10
  • Platform(s) (iOS, Android, or both?): both

Most helpful comment

please share your solution so others can get the benfits

All 6 comments

after a little workaround, I found a solution;

Thanks @FaridSafi for a great module

please share your solution so others can get the benfits

Added 3rd option in CustomActions
const options = ['Choose From Library', 'Send Location','Camera' ,'Cancel'];

I used another module.
var ImagePicker = require('react-native-image-picker');

added 3rd Case in Switch statement
case 2:
ImagePicker.launchCamera({title:"Please click photo"}, (response) => {
this.props.onSend([{
image: response.uri,
}]);
this.setImages([]);
});
break;
ImagePicker.launchCamera will not work in simulator

@riteshvish How did you call "CustomActions.js" from "App.js" file. Can you show your "App.js" file? Or What actually you did to your code to integrate Camera Feature.

@sachinsinghh
import CustomActions from './chat/CustomActions'; (your file path);
renderCustomActions(props) {
return (
{...props}
/>
);
}

...
renderActions={this.renderCustomActions}
...
/>

@riteshvish Thanx

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tafelito picture tafelito  路  3Comments

redwind picture redwind  路  3Comments

pentarex picture pentarex  路  3Comments

luisfuertes picture luisfuertes  路  3Comments

jasonwcfan picture jasonwcfan  路  3Comments