Chat / iOS
Chat iOS v4
Chat iOS
Chat
iOS
Home
/
Chat
/
iOS
/
Message
This is the new Docs for Chat SDK v4 for iOS. To see the previous Docs, click here.

Track file upload progress using a handler

If needed, you can track the progress of file upload by passing the progressHandler: code block as an argument to a parameter when calling the sendFileMessage(params:progressHandler:completionHandler:) method.

let fileMessage = channel.sendFileMessage(
    params: params,
    progressHandler: { reqId, bytesSent, totalBytesSent, totalBytesExpectedToSend in
        let progress = CGFloat(totalBytesSent) / CGFloat(totalBytesExpectedToSend)
    },
    completionHandler: { message, error in
        guard error == nil else {
            // Handle error.
            return
        }

    }
)