File Message

To send a file message, you must provide a valid local file URL instance of the selected file and file name for the file. The default file name is file. The SDK will check the size of the data whether it is exceeding the limit or not before sending it to the server. If the size of the data is more than the limit, the callback will return an Error object with the Dictionary of the error information that you can parse and then show an error message.

You can also provide an optional caption as part of the message. You can add up to 1,000 characters of text caption per message.

let messageId = messageRepository.createFileMessage(withChannelId: "channel-123",
                                                             file: URL(string: "local-file-path")!,
                                                         filename: nil, 
                                                          caption: nil, 
                                                             tags: nil, 
                                                         parentId: nil) { message, error in
     // Handle message creation result.
}

token = messageRepository.getMessage(messageId)?.observe { liveMessage, error in
    // Observe message data changes.
}

Viewing File Message

The server will automatically generate a filename for you under the fileName key on the message data property, based on the file name that you choose to use. We advise that you handle the file size issues beforehand, as currently our limitation is set to less than 1 GB.

Last updated