最近使用Xcode 7 寫代碼,發送網路請求提示:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file
找查資料後發現,新特性要求App內訪問網絡請求,要採用 HTTPS 協議。
但是現在公司的項目使用的是 HTTP
協議,使用私有加密方式保證數據安全。現在也不能馬上改成 HTTPS
協議傳輸。
最終找到以下解決辦法:
- 在Info.plist中添加
NSAppTransportSecurity
類型Dictionary
。 - 在
NSAppTransportSecurity
下添加NSAllowsArbitraryLoads
類型Boolean
,值設爲YES