在新發布的iOS9系統上圍繞用戶數據的安全性和體驗新增了一些安全特性,同時也影響了應用的實現以及集成方式,爲了保證良好的穩定性和體驗,須要作以下處理:
(ps.因爲目前QQ SDK官方並未給出明確的白名單,故QQ相關白名單可能並不夠完善,咱們會不斷進行補充,也歡迎開發者提供建議)
1. HTTP傳輸安全
以iOS9 SDK編譯的工程會默認以SSL安全協議進行網絡傳輸,即HTTPS,若是依然使用HTTP協議請求網絡會報系統異常並中斷請求。目前可用以下兩種方式保持用HTTP進行網絡鏈接:
A、在info.plist中加入安全域名白名單(右鍵info.plist用source code打開)
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>log.umsns.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
<key>sns.whalecloud.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
<!-- 集成新浪微博對應的HTTP白名單-->
<key>sina.cn</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>weibo.cn</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>weibo.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<!-- 新浪微博-->
<!-- 集成微信受權對應的HTTP白名單-->
<key>api.weixin.qq.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<!-- 微信受權-->
</dict>
</dict>
注:以上平臺若是沒有集成直接刪除相應配置便可
B、在info.plist的NSAppTransportSecurity下新增NSAllowsArbitraryLoads並設置爲YES,指定全部HTTP鏈接均可正常請求
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
</true>
</dict>
2. 應用跳轉(SSO等)
若是你的應用使用瞭如SSO受權登陸或跳轉分享功能,在iOS9下就須要增長一個可跳轉的白名單,指定對應跳轉App的URL Scheme,不然將在第三方平臺判斷是否跳轉時用到的canOpenURL時返回NO,進而只進行webview受權或受權/分享失敗。
一樣在info.plist增長:
<key>LSApplicationQueriesSchemes</key>
<array>
<!-- 微信 URL Scheme 白名單-->
<string>wechat</string>
<string>weixin</string>
<!-- 新浪微博 URL Scheme 白名單-->
<string>sinaweibohd</string>
<string>sinaweibo</string>
<string>sinaweibosso</string>
<string>weibosdk</string>
<string>weibosdk2.5</string>
<!-- QQ和Qzone URL Scheme 白名單-->
<string>mqqapi</string>
<string>mqq</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqconnect</string>
<string>mqqopensdkdataline</string>
<string>mqqopensdkgrouptribeshare</string>
<string>mqqopensdkfriend</string>
<string>mqqopensdkapi</string>
<string>mqqopensdkapiV2</string>
<string>mqqopensdkapiV3</string>
<string>mqzoneopensdk</string>
<string>mqqopensdkapiV3</string>
<string>mqqopensdkapiV3</string>
<string>wtloginmqq</string>
<string>wtloginmqq2</string>
<string>mqzone</string>
<string>mqzonev2</string>
<string>mqzoneshare</string>
<string>wtloginqzone</string>
<string>mqzonewx</string>
<string>mqzoneopensdkapiV2</string>
<string>mqzoneopensdkapi19</string>
<string>mqzoneopensdkapi</string>
<string>mqzoneopensdk</string>
</array>
注:以上平臺若是沒有集成直接刪除相應配置便可
3. 應用瘦身(App thining)
iOS9 SDK新增了對App瘦身的功能,詳情見App thining。目前各個第三方平臺正在進行App thining的支持,因此爲了正常使用第三方SDK及分享SDK,須要在Build Setting中將**Enable bitcode**關閉,或設置編譯標識ENABLE_BITCODE=NO。
注:bitcode僅在Xcode7以上顯示並默認開啓。