How to send an image message only ? (without sending a text as well)
See original GitHub issueIssue Description
I simply want to send an image without typing any text ? I am using react-native-image-picker and i currently can send an image with a text , but what if i want to send an image only ? I tried alwaysShowSend and try to send but nothing happens unless the text field is not empty The docs are very vague on this …
Steps to Reproduce / Code Snippets
<GiftedChat
messages={friendMsgs}
onSend={messages => this.onSend(messages, this.state.image)}
user={{
_id: user && user.id,
name: user && user.firstName,
avatar: user && user.profilemage
}}
text={this.state.text}
alwaysShowSend={
this.state.text ? true : false || this.state.image ? true : false
}
onInputTextChanged={text => this.setState({ text })}
renderLoading={() => <Loading />}
onLoadEarlier={this.loadMessages.bind(this, userParams)}
isLoadingEarlier={loading}
isAnimated
renderAvatarOnTop
loadEarlier={friendMsgs.length >= 20}
scrollToBottom
scrollToBottomComponent={() => (
<Ionic name='ios-arrow-round-down' size={30} color='#000' />
)}
extraData={this.state}
renderBubble={props => {
const color = props.currentMessage.read ? '#0084ff' : '#389bff';
return (
<Bubble
{...props}
wrapperStyle={{ right: { backgroundColor: color } }}
/>
);
}}
renderActions={() => (
<Feather
style={styles.uploadImage}
onPress={this.uploadImage}
name='image'
size={30}
color='#000'
/>
)}
/>
onSend(messages = [], image) {
const { socket, user, navigation } = this.props;
const { friendMsgs } = this.props.history;
const receiver = navigation.getParam('user');
if (socket && socket.readyState === 1) {
const msg = {
...messages[0],
image
};
const sendMsg = GiftedChat.append(friendMsgs, msg);
const data = {
senderId: user && user.id,
receiverType: 'user',
messageType: 'text',
receiverId: receiver.id,
read: false,
content: messages[0].text
};
this.props.sendMsg(data, sendMsg);
}
}
Expected Results
[FILL THIS OUT]
Additional Information
- React version: 16.8.3
- React Native version: 0.59.9
- react-native-gifted-chat version: 0.9.11
- Platform(s) (iOS, Android, or both?): both
Issue Analytics
- State:
- Created 4 years ago
- Comments:9
Top Results From Across the Web
How to send an image message only ? (without sending a text ...
You Need to make the custom send button, to do this: import { GiftedChat ...
Read more >How to Send Messages That Automatically Disappear - WIRED
Head to your conversation list in the Instagram app, then open the thread that you want to send the disappearing message to (tap...
Read more >Android: Send Picture in Email or Text Message - Technipages
Send Photo via Text Message. Open the “Messages” app. Select the + icon, then choose a recipient or open an existing message thread....
Read more >Use message effects with iMessage on your iPhone, iPad and ...
Tap the Send button send message icon or tap Done to add a personal message. If you don't want to send the photo,...
Read more >Top 7 Ways To Fix Sending Picture Messages On Android
Have you been trying to send a family picture via text message to your grandma who doesn't use a smartphone but to no...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok true. Then this should work right?
where
customOnPress
replaces this in Send.tsx:And maybe also include the
disabled
stuff from my previous post if that’s at all relevant.The onSend function is not invoking if the text field is empty