yarn add react-native-image-picker
Install the native image picker by running the following command:
yarn add react-native-image-picker
npx expo install expo-image-picker
This shall give you a UI to select images from the gallery using native image picker or take a picture from the camera or alternatively select a file.
You don’t need any permission for the native image picker on Android.
Please follow the post installation steps as mentioned in the react-native-image-picker.
You can customize what happens on clicking the AttachButton
by passing your own onPress
function to the handleAttachButtonPress
of the Channel
component.
import { useCallback } from "react";
import { Channel } from "stream-chat-react-native";
const App = () => {
const handleAttachButtonPress = useCallback(async () => {
// Your custom logic here
}, []);
return (
<Channel
channel={channel}
handleAttachButtonPress={handleAttachButtonPress}
/>
);
};
The other alternative is customizing the AttachButton
component itself.
import { AttachButton } from "stream-chat-react-native";
const CustomAttachButton = (props) => {
const { onPress } = props;
const handlePress = async () => {
// Your custom logic here
};
return <AttachButton onPress={handlePress} />;
};
const App = () => {
return <Channel channel={channel} AttachButton={CustomAttachButton} />;
};