Home
/
UIKit
/
iOS
/
Open channel

File sharing

File sharing is a feature that allows users to send files such as images, audio files, and videos while chatting in a channel. File sharing appears in the messageInput component of the SBUOpenChannelViewController class.

In UIKit for iOS, there are currently four different types of file messages that users can send: image file, video file, audio file, and document file. These files can be shared with other participants 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.

Showing different types of file messages.

Note : In order to use the file sharing feature, you must first create a channel and enable chat service. To learn how to allow users to chat in a channel, refer to Chat in a channel.

Customize the UI for file sharing

You can customize the UI for file sharing using SBUMessageCellTheme in the SBUTheme, SBUStringSet, and SBUIconSet.

SBUMessageCellTheme

The following table shows customizable theme properties of file sharing.

CategoryPropertyDescription

File message

fileIconBackgroundColor

The background color of the file icon.

File message

fileIconColor

The color of the file icon.

File message

fileMessageNameFont

The text font of the file message name element.

File message

fileMessageLeftTextColor

The text color of the left side of a file message.

File message

fileMessageRightTextColor

The text color of the right side of a file message.

File message

fileMessagePlaceholderColor

The text color of a file message's placeholder.

SBUStringSet

The following table shows a property of SBUStringSet that can be modified to customize file sharing. The SBUStringSet is a set of strings used to compose the screen. You need to modify the stringSet values in advance if you want to make changes to the screen.

Property nameDescription

Channel_Success_Download_file

A text for file save completion.

Channel_Failure_Download_file

A text for file save failure.

Channel_Failure_Open_file

A text for file open failure.

SBUIconSet

The following table shows customizable file sharing icons.

Icon nameImageDescription

iconAdd

Add icon

Add a file.

iconDocument

Document icon

Select a file to send.

iconFileAudio

Audio File icon

An audio file message.

iconFileDocument

Document File icon

A document file message.

iconGif

Gif icon

A GIF, Graphics Interchange Format, file message.

iconPlay

Play icon

Play a video file message.


Image compression

UIKit for iOS 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 the data usage.

The following table lists properties in the SBUGlobals class that are related to image compression. These properties can be customized before you initialize UIKit or create a new channel.

PropertyTypeDescription

UsingImageCompression

Bool

Determines whether to compress the image when sending an image file message. (Default: false)

imageCompressionRate

CGFloat

The value of the compression rate to apply to the image. Acceptable values are 0.0 to 1.0, inclusive. (Default: 0.85)

imageResizingSize

CGSize

The value of the size dimensions to apply to the image. (Default: device screen size)

Note: To compress an image without changing the size dimensions, use the imageCompressionRate property. To resize the image, use the imageResizingSize property.

Objective-C
Swift
Light Color Skin
Copy
[SBUGlobals setUsingImageCompression:YES];
[SBUGlobals setImageCompressionRate:0.85];
[SBUGlobals setImageResizingSize:CGSizeMake(480, 480)];
Light Color Skin
Copy
SBUGlobals.UsingImageCompression = true
SBUGlobals.imageCompressionRate = 0.85
SBUGlobals.imageResizingSize = CGSize(width: 480, height: 480)