failed to find PDF header: `%PDF' not found iOS, PDFKit

I'm downloading a pdf and show it to to the end user using PDFKit. most of the time it works properly. for some cases, it gives me an error called

failed to find PDF header: `%PDF' not found

I went through several readings and StackOverflow questions like Question. but still didn't figure out the solution to outcome of this problem. in some articles, it says it is a bug from Apple. isn't it fixed it yet?

here is how I'm downloading the pdf

    let destination: DownloadRequest.DownloadFileDestination = { _, _ in
        let documentsURl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
        let fileurl = documentsURl.appendingPathComponent(mydocumentname + ".pdf")
        return (fileurl, [.removePreviousFile, .createIntermediateDirectories])
    }

    Alamofire.download(urlrequest!, to: destination).responseData { (response) in
        switch response.result {
        case .success( _):
            completion(response.destinationURL)
        case .failure(let err):
        }
    }

this works fine in most cases. but fail in some cases with the above error. does anyone know a solution for this? hope your help with this. have a nice day.