2016-12-02 5 views
0

- > OK

- >するうまくいきません。何も起こらない

答えて

1

デフォルトでは、iOS 9以降ではすべての接続がhttpsでなければなりません。 2番目のURLのWebサイトがhttps://をサポートしていない場合、ダウンロードは失敗します。

私は

-2

その後方法の下に使用してAlamofire 4.0スウィフト3.0

を使用して

<?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> 

PLIST

に追加してください。あなたがダウンロードから取り戻すエラーコードを確認することをお勧め、あなたは任意のものをダウンロードすることができます、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) 
     } 
    } 
0

あなたは、HTTP接続でURLを使用し、その後、あなたのInfo.plistファイルに次の のApp交通セキュリティ設定を追加し、その中の任意のロードを許可し、YESに値を設定するサブセクションを追加したい場合。

enter image description here

関連する問題