/ SDKs / iOS
SDKs
Chat SDKs iOS v4
Chat SDKs iOS
Chat SDKs
iOS
Version 4

Track file upload progress using a handler

Copy link

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
        }

    }
)