Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] android – How can I send images/video and voice messages in React-native-Gifted-chat using render actions?

Posted on November 14, 2022

Solution 1 :

Gifted chat has renderActions property itself so just need to create custom action to upload image/video and voice.

Here, I am attaching code for upload documents like PDF/Doc file.

To upload image/video you just need to change that package instead of I’ve used document-picker

const renderActions = (props) => {
    return (
        <Actions
            {...props}
            options={{
                ['Document']: async (props) => {
                    try {
                        const result = await DocumentPicker.pick({
                            type: [DocumentPicker.types.pdf],
                        });
                       console.log("image file",result)
                    } catch (e) {
                        if (DocumentPicker.isCancel(e)) {
                            console.log("User cancelled!")
                        } else {
                            throw e;
                        }
                    }

                },
                Cancel: (props) => { console.log("Cancel") }
            }}
            onSend={args => console.log(args)}
        />
    )
};

Gifted-chat component


                   <GiftedChat
                    messages={messages}
                    showAvatarForEveryMessage={true}
                    onSend={messages => onSend(messages)}
                    renderActions={() => renderActions()}
                    user={{
                        _id: 2,
                        name: 'React Native',
                        avatar: 'https://placeimg.com/140/140/any',
                    }}
                    renderCustomView={renderCustomView}
                />
 

Problem :

I want to send images/video in chat application, developed using React-native-gifted-chat and Firebase, How can I create action for them and call that actions to upload in firebase and send images/video?

Here is my code.

handleSendImage = () => {
    console.log("handleSendImage");
  };
  renderActions(props) {
    return (
      <Actions
        {...props}
        // containerStyle={{
        //   width: 70,
        // }}
        icon={() => (
          <Icon
            name={"camera"}
            size={30}
            color={colors.btnBg}
            font={"FontAwesome"}
            onPress={this.handleSendImage}
          />
        )}
        onSend={(args) => console.log(args)}
      />
    );
  }

      

<GiftedChat
            placeholder={"Hey!"}
            alwaysShowSend
            messages={messages}
            onSend={(newMessage) => this.onSend(this.chatID(), newMessage)}
            renderInputToolbar={this.renderInputToolbar}
            renderActions={this.renderActions}
            user={{
              _id: senderId,
              name: senderName,
            }}
          />

How can I click on particular actions and send voice and images/video respectively?

Comments

Comment posted by Oliver D

Are you found a solution?

Comment posted by JPithwa

yes, @OliverD, able to develop with Actions.

Comment posted by Shyam

@JaydeepPithwa Can you post the solution here?

Comment posted by Harshil Jasoliya

Try adding your actions to

READ  [ANSWERED] android - Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2. How to solve it?
Powered by Inline Related Posts

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress