今天升級(jí)Xcode 7.0 bata發(fā)現(xiàn)網(wǎng)絡(luò)訪(fǎng)問(wèn)失敗。
輸出錯(cuò)誤信息
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
Google后查證,iOS9引入了新特性App Transport Security (ATS)诉探。詳情:App Transport Security (ATS)
新特性要求App內(nèi)訪(fǎng)問(wèn)的網(wǎng)絡(luò)必須使用HTTPS協(xié)議负拟。
但是現(xiàn)在公司的項(xiàng)目使用的是HTTP協(xié)議,使用私有加密方式保證數(shù)據(jù)安全∮悼蹋現(xiàn)在也不能馬上改成HTTPS協(xié)議傳輸昌犹。
最終找到以下解決辦法:
在Info.plist中添加NSAppTransportSecurity類(lèi)型Dictionary监婶。
在NSAppTransportSecurity下添加NSAllowsArbitraryLoads類(lèi)型Boolean,值設(shè)為YES