Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit updating README.md to include new Quick Reply feature. #881

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* InputToolbar avoiding keyboard
* Redux support
* System message
* Quick Reply messages

## Dependency

Expand Down Expand Up @@ -123,9 +124,26 @@ See [`example/App.js`](example/App.js) for a working demo!

See the files in [`example-slack-message`](example-slack-message) for an example of how to override the default UI to make something that looks more like Slack -- with usernames displayed and all messages on the left.

## Quick Reply example

```jsx
onQuickReply(quickReply) {
if(quickReply.contentType === "text") {
// send text message
} else if (quickReply.contentType === "location") {
// send location
} else if (quickReply.contentType === "camera") {
// open camera then send video / image
}
// infinite possibilities
}
...
<GiftedChat onQuickReply={quickReply => this.onQuickReply(quickReply)}>
```

## Message object

e.g. Chat Message
### e.g. Chat Message

```js
{
Expand All @@ -141,8 +159,28 @@ e.g. Chat Message
// Any additional custom parameters are passed through
}
```
### e.g. Chat Message with Quick Reply options

e.g. System Message
```js
{
_id: 1,
text: 'My message',
"quickReplies":[
{
"contentType":"text",
"title":"Yes",
"imageUrl":"http://example.com/img/yes.png"
},
{
"contentType":"text",
"title":"No",
"imageUrl":"http://example.com/img/no.png"
}
]
}
```

### e.g. System Message

```js
{
Expand Down Expand Up @@ -215,6 +253,9 @@ e.g. System Message
/>
```

* **`onQuickReply`** _(Function)_ - Callback when sending a quick reply (to backend server)
* **`renderQuickReply`** _(Function)_ - Custom quick reply view

## Imperative methods

* `focusTextInput()` - Open the keyboard and focus the text input box
Expand Down