1. 程式人生 > >iOS9 網絡請求修改

iOS9 網絡請求修改

lean https secure ans load cti 但是 數據安全 info

升級為iOS9後,默認請求類型為https,如何使用http進行請求會報錯

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
原因 iOS9引入了新特性App Transport Security (ATS)

新特性要求App內訪問的網絡必須使用HTTPS協議。
但是現在公司的項目使用的是HTTP協議,使用私有加密方式保證數據安全。現在也不能馬上改成HTTPS協議傳輸。

最簡單的解決方案:
1,在info.plist文件中添加App Transport Security Settings 類型是一個Dictionary
2,在App Transport Security Settings下添加Allow Arbitrary Loads 類型Boolean,值設為YES

iOS9 網絡請求修改