昨天升級(jí)了Xcode 7 , 遇到的問題,從友盟的幫助文檔看到俏让,簡單的第三方適配如下:
在新發(fā)布的iOS9系統(tǒng)上圍繞用戶數(shù)據(jù)的安全性和體驗(yàn)新增了一些安全特性,同時(shí)也影響了應(yīng)用的實(shí)現(xiàn)以及集成方式茬暇,為了保證良好的穩(wěn)定性和體驗(yàn)首昔,需要做如下處理:
1. HTTP傳輸安全
以iOS9 SDK編譯的工程會(huì)默認(rèn)以SSL安全協(xié)議進(jìn)行網(wǎng)絡(luò)傳輸,即HTTPS而钞,如果依然使用HTTP協(xié)議請(qǐng)求網(wǎng)絡(luò)會(huì)報(bào)系統(tǒng)異常并中斷請(qǐng)求沙廉。目前可用如下兩種方式保持用HTTP進(jìn)行網(wǎng)絡(luò)連接:
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>
<!-- 集成新浪微博對(duì)應(yīng)的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>
<!-- 新浪微博-->
<!-- 集成微信授權(quán)對(duì)應(yīng)的HTTP白名單-->
<key>api.weixin.qq.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<!-- 微信授權(quán)-->
</dict>
</dict>
** 注:以上平臺(tái)如果沒有集成直接刪除相應(yīng)配置即可 **
B臼节、在info.plist的NSAppTransportSecurity下新增NSAllowsArbitraryLoads并設(shè)置為YES撬陵,指定所有HTTP連接都可正常請(qǐng)求
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
</true>
</dict>
2. 應(yīng)用跳轉(zhuǎn)(SSO等)
如果你的應(yīng)用使用了如SSO授權(quán)登錄或跳轉(zhuǎn)分享功能,在iOS9下就需要增加一個(gè)可跳轉(zhuǎn)的白名單网缝,指定對(duì)應(yīng)跳轉(zhuǎn)App的URL Scheme巨税,否則將在第三方平臺(tái)判斷是否跳轉(zhuǎn)時(shí)用到的canOpenURL時(shí)返回NO,進(jìn)而只進(jìn)行webview授權(quán)或授權(quán)/分享失敗粉臊。
同樣在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>
** 注:以上平臺(tái)如果沒有集成直接刪除相應(yīng)配置即可 **
3. 應(yīng)用瘦身(App thining)
iOS9 SDK新增了對(duì)App瘦身的功能草添,詳情見App thining。目前各個(gè)第三方平臺(tái)正在進(jìn)行App thining的支持扼仲,所以為了正常使用第三方SDK及分享SDK远寸,需要在Build Setting中將Enable bitcode關(guān)閉,或設(shè)置編譯標(biāo)識(shí)ENABLE_BITCODE=NO抄淑。
注:bitcode僅在Xcode7以上顯示并默認(rèn)開啟。
4. 從友盟社會(huì)化分享iOS文檔 轉(zhuǎn)載
注:本文首發(fā)于 iHTCboy's blog驰后,如若轉(zhuǎn)載肆资,請(qǐng)注明來源。