iOS-XCode7 And iOS9 适配

iOS 9系统更新,需要对其进行适配。

App Transport Security

iOS9以后,默认支持Https,如果依然要使用Http,需要在info.plist里加上一项。

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

否则,会遇到报错:

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跳转

iOS9以后,App互相之间不能直接通过openUrl进行跳转,必须在info.plist文件里加上一项。

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>URL</string>
</array>

这里的URL是在的plist的URLTypes里面设置的:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>XXX</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>URL</string>
        </array>
    </dict>
</array>

否则,会遇到报错:

This app is not allowed to query for scheme xxx