iOS9 的那些坑

1.在Info.plist中添加NSAppTransportSecurity類型Dictionary。
2.在NSAppTransportSecurity下添加NSAllowsArbitraryLoads類型Boolean,值設(shè)為YES


Paste_Image.png

用source code打開(kāi)如下:

<key>NSAppTransportSecurity</key>
<dict>
    <!--Connect to anything (this is probably BAD)-->
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
針對(duì)個(gè)別網(wǎng)站配置

![D5PO]DYP53WT9ZRG%@$VY.jpg](http://upload-images.jianshu.io/upload_images/228486-2153743117f36c38.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

1.子域名同樣適用
NSIncludesSubdomains Boolean類型 YES
2.禁用ForwardSecrecy
NSExceptionRequiresForwardSecrecy Boolean類型 NO
3.允許簽名過(guò)期 或者不匹配情況
NSTemporaryExceptionAllowsInsecureHTTPLoads Boolean類型 YES

用source code打開(kāi)如下:

<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>baidu.com</key>
<dict>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
iOS 9 分享適配

URL Scheme 用于應(yīng)用程序的分享或者跳轉(zhuǎn)到其他平臺(tái)的授權(quán),分享或者授權(quán)后再跳回來(lái)
在iOS 8 沒(méi)有做限制,但是在iOS 9 需要將在外部調(diào)用的URL Scheme列為白名單才可以跳轉(zhuǎn)
沒(méi)做適配的情況下 會(huì)報(bào)錯(cuò):
-canOpenURL: failed for URL: "mqq://" - error: "This app is not allowed to query for scheme mqq"
解決辦法:在info.plist設(shè)置LSApplicationQueriesSchemes(數(shù)組),在里面添加用到的URL Scheme

Paste_Image.png

用source code打開(kāi)如下:

<key>LSApplicationQueriesSchemes</key>
<array>
    <!-- 微信 URL Scheme 白名單-->
    <string>wechat</string>
    <string>weixin</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>wtloginmqq</string>
    <string>wtloginmqq2</string>
    <string>mqqwpa</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>

============================================
注:

 <!-- 集成微信、QQ、Qzone、騰訊微博授權(quán)對(duì)應(yīng)的HTTP白名單-->
 <key>qq.com</key>
 <dict> 
 <key>NSIncludesSubdomains</key>
 <true/> 
 <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> 
 <true/>
 <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> 
 <false/>
 </dict>
 <!-- 騰訊授權(quán)-->

============================================

另外 還要注意iOS 9 以后可能有些lable的內(nèi)容是顯示不全的!
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容