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.

Cancel an in-progress file upload

Using the cancelUploadingFileMessage(requestId:completionHandler:) method, you can cancel an in-progress file upload while it hasn't been completed yet. If the function operates successfully, the value of true is returned to completionHandler:.

Note: If you attempt to cancel the upload after it has already been completed or canceled, or the attempt results in an error, the function returns the value of false.

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

// Cancel uploading a file in the file message.
GroupChannel.cancelUploadingFileMessage(requestId: fileMessage.requestId) { result, error in
    guard error == nil else {
        // Handle error.
        return
    }
}