iOS9 的那些坑

作者: X先生_vip | 来源:发表于2015-10-20 10:01 被阅读814次

    1.在Info.plist中添加NSAppTransportSecurity类型Dictionary。
    2.在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES


    Paste_Image.png

    用source code打开如下:

    <key>NSAppTransportSecurity</key>
    <dict>
        <!--Connect to anything (this is probably BAD)-->
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    
    针对个别网站配置

    ![D5PO]DYP53WT9ZRG%@$VY.jpg](http:https://img.haomeiwen.com/i228486/2153743117f36c38.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

    1.子域名同样适用
    NSIncludesSubdomains Boolean类型 YES
    2.禁用ForwardSecrecy
    NSExceptionRequiresForwardSecrecy Boolean类型 NO
    3.允许签名过期 或者不匹配情况
    NSTemporaryExceptionAllowsInsecureHTTPLoads Boolean类型 YES

    用source code打开如下:

    <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 用于应用程序的分享或者跳转到其他平台的授权,分享或者授权后再跳回来
    在iOS 8 没有做限制,但是在iOS 9 需要将在外部调用的URL Scheme列为白名单才可以跳转
    没做适配的情况下 会报错:
    -canOpenURL: failed for URL: "mqq://" - error: "This app is not allowed to query for scheme mqq"
    解决办法:在info.plist设置LSApplicationQueriesSchemes(数组),在里面添加用到的URL Scheme

    Paste_Image.png
    用source code打开如下:
    <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、腾讯微博授权对应的HTTP白名单-->
     <key>qq.com</key>
     <dict> 
     <key>NSIncludesSubdomains</key>
     <true/> 
     <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> 
     <true/>
     <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> 
     <false/>
     </dict>
     <!-- 腾讯授权-->
    

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

    另外 还要注意iOS 9 以后可能有些lable的内容是显示不全的!

    相关文章

      网友评论

      • 33a02bf71691:URL Scheme有没有办法代码写入plist文件呢,因为我们的URL Scheme是后台给的 而且数量还不固定

      本文标题:iOS9 的那些坑

      本文链接:https://www.haomeiwen.com/subject/ymvbcttx.html