File sharing
File sharing is a feature that allows users to send files during a chat, such as images, audio files, and videos. File sharing appears in the MessageList component of the GroupChannelModule
.
There are currently four types of file messages that users can send: image file, video file, audio file, and document file. These files can be shared with other members in the channel by either directly taking a photo with the camera on a mobile device or uploading an image, video, audio, or document file from the sender’s mobile device.
Note: In order to use the file sharing feature, you must first create a channel and enable the chat service. To learn how to allow users to chat in a channel, refer to the chat in a group channel page.
Customize the UI for file sharing
You can customize the component for file sharing by using renderMessage
as shown in the code below.
Color resource
To customize the color and style of message items, you have to change the values of UIKitColors
in UIKitTheme
as shown below.
Category | Property | Description |
---|---|---|
message | textEdited | Specifies the text color of an edited message. |
message | textMsg | Specifies the text color of a message. |
message | textSenderName | Specifies the text color of the message sender's name. |
message | textTime | Specifies the text color of the time that a message was sent. |
message | background | Specifies the background color of a message bubble. |
Note: To learn how to customize the theme colors, refer to the color resource page and the themes overview page.
String resource
The following table shows customizable properties of StringSet
.
Category | Property | Description |
---|---|---|
GROUP_CHANNEL | MESSAGE_BUBBLE_FILE_TITLE | A text for the file message. |
GROUP_CHANNEL | DIALOG_ATTACHMENT_CAMERA | A text for using the camera to send a photo. |
GROUP_CHANNEL | DIALOG_ATTACHMENT_PHOTO_LIBRARY | A text for using the photo library to send a photo. |
GROUP_CHANNEL | DIALOG_ATTACHMENT_FILES | A text for sending files to a channel. |
TOAST | OPEN_CAMERA_ERROR | A text for when there's an error to open the camera. |
TOAST | OPEN_PHOTO_LIBRARY_ERROR | A text for when there's an error to access the photo library. |
TOAST | OPEN_FILES_ERROR | A text for when there's an error to open files. |
TOAST | DOWNLOAD_START | A text for when a file message is downloading. |
TOAST | DOWNLOAD_OK | A text for when the file was successfully downloaded. |
TOAST | DOWNLOAD_ERROR | A text for when the file couldn't be downloaded. |
Icon resource
The following table shows customizable file sharing icons.
Icon | Image | Description |
---|---|---|
add | An icon used to select and add files. | |
document | An icon used to select a file to send. | |
file-audio | An icon indicating an audio file message. | |
file-document | An icon indicating a document file message. | |
play | An icon indicating a video file message. |
Image compression
UIKit for React Native allows users to compress images when sending them to other users in the channel on a client app. By reducing the image size, they can send and receive image files faster and minimize the usage of data storage as well as data usage. Image compression can be applied to the following image types: jpg
, jpeg
, and png
.
The following table lists properties of the imageCompression
prop in the SendbirdUIKitContainer
component.
Property | Type | Description |
---|---|---|
compressionRate | number | Specifies the value of the compression rate to apply to the image. (Default: |
width | number | Specifies the maximum value of |
height | number | Specifies the maximu value of |
To compress an image without changing the value of width
and height
, use the compressionRate
property. To resize the image, use the width
and height
properties. If you assign values to compressionRate
, width
, and height
simultaneously, the image will be both compressed and resized. If you don't want to compress the image, set chatOptions.enableImageCompression
in the SendbirdUIKitContainer
component to false
. The default value is set to true
.