Please add in Plist
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSExceptionDomains</key> <dict> <key>akamaihd.net</key> <dict> <key>NSExceptionRequiresForwardSecrecy</key> <false/> <key>NSIncludesSubdomains</key> <true/> </dict> <key>facebook.com</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSExceptionRequiresForwardSecrecy</key> <false/> <key>NSIncludesSubdomains</key> <true/> </dict> <key>fbcdn.net</key> <dict> <key>NSExceptionRequiresForwardSecrecy</key> <false/> <key>NSIncludesSubdomains</key> <true/> </dict> <key>graph.facebook.com</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSExceptionRequiresForwardSecrecy</key> <false/> <key>NSIncludesSubdomains</key> <true/> </dict> </dict> </dict> </plist>
Then using Alamofire 4.0 Swift 3.0
Using below method, you can download any thing, ex. PDF
// Mark:- Download File func DownloadFile(strFileUrl : String, strFileName : String, success:@escaping (_ strResultURL: String) -> Void , failure:@escaping (_ responseObject:AnyObject) -> Void) { let destination: DownloadRequest.DownloadFileDestination = { _, _ in let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] let fileURL = documentsURL.appendingPathComponent("\(strFileName)") return (fileURL, [.removePreviousFile, .createIntermediateDirectories]) } Alamofire.download(strFileUrl, to: destination).response { response in if SVProgressHUD.isVisible() { SVProgressHUD.dismiss() } if response.error == nil { success("\(response.destinationURL!)") } else { failure(response.error as AnyObject) } }.downloadProgress { (progress) in print("Download Progress: \(progress.fractionCompleted)") SVProgressHUD.showProgress(Float(progress.fractionCompleted), status: AppAlertMsg.KDownloadingPDFs) } }