zoukankan      html  css  js  c++  java
  • iOS9适配

    一、App Transport Security

    xcode7安装后,你会发现ios9之后后默认所有http请求都无法继续有效,但是基于现状,我们并不能这么快改成https请求,所以基本上大多数app都会选择兼容老模式。

    如果服务不改变,则客户端info.plist的根需加下面的键值。(这些key可以手动在project的info里直接添加和修改)

    简单信任所有http服务器

    <key>NSAppTransportSecurity</key>

    <dict>

          <key>NSAllowsArbitraryLoads</key> 

      <true/>

    </dict> 

    或者另外严谨一些

    <key>NSAppTransportSecurity</key>

    <dict>  

      <key>NSExceptionDomains</key>  

          <dict>    

              <key>yourserver.com</key>    

                  <dict>      

                  <!--Include to allow subdomains-->      

                  <key>NSIncludesSubdomains</key>

                      <true/>

                  <!--Include to allow insecure HTTP requests-->                

          <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>     

                      <true/>

                  <!--Include to specify minimum TLS version-->      

                  <key>NSTemporaryExceptionMinimumTLSVersion</key>      

                      <string>TLSv1.2</string>    

                  <!--whether domain support forward secrecy

    using ciphers, if not support, set false-->

                  <key>NSExceptionRequiresForwardSecrecy</key>

                      <false/>

                  </dict>  

          </dict>

    </dict> 

    另外由于苹果的https的限制(注意理论上苹果ATS生效的是调用NSURLConnection, CFURL, or NSURLSession APIs的所有连接),还不仅仅限于任何https,还必须满足一定的其他要求,比如加密算法的要求,TLS的协议版本等。(详情查看https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/)

    比如网上有人分析了百度的https就不能满足默认的苹果https安全传输要求,因为它的TLS虽然满足TLS1.2,但是加密算法是:SHA-1 with RSA Encryption ,所以依然会被报警,所以,这种exception的情况也需要额外标注,上面的官方连接也有说明,即添加NSExceptionRequiresForwardSecrecy,并设置为false,禁止forword secrecy。

    二、bitcode

    xcode7 默认开启,bitcode(iwatch需要),则会导致部分第三方框架报错。(比如友盟的错误)

    libMobClickLibrary.a(MobClick.o)‘ does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7

    这是要么更新库,要么可以在 build setting 中,搜索bitcode,并把enable bitcode 设置为 NO,这个因各自app情况而定,实际上本身不会降低上传包大小,只是开启后能降低用户下载的大小。苹果会自动根据用户自身的设备选择相关架构的下载。

    三、iOS9安装企业证书打包的app

    企业证书打包的app,安装到手机里面后第一次打开app。不会像以前一样自动提示,信任还是不信任该证书;

    这是个时候需要iOS9 设置-》通用-》描述文件-》企业级应用 中信任对应的企业开发者。

    四、iOS9 URL Schemes

    苹果新上线urlScheme的限制

    If you call the “canOpenURL” method on a URL that is not in your whitelist, 

      it will return “NO”, even if there is an app installed that has registered to handle this scheme.

     A “This app is not allowed to query for scheme xxx” syslog entry will appear.

     

    If you call the “openURL” method on a URL that is not in your whitelist, 

      it will fail silently. A “This app is not allowed to query for scheme xxx” syslog entry will appear.

    更多信息:WWDC 2015 Session 703: “Privacy and Your App” https://developer.apple.com/videos/wwdc/2015/?id=703

    因此现在要搞分享的时候,除了要在项目info URL Types中设置URL Schemes,还需要在info.plist里面增加可信任的调用app url scheme,否则回报如下错误。

    -canOpenURL: failed for URL: “weixin://app/wx********/” - error: “This app is not allowed to query for scheme weixin”

    只需要添加如下代码即可,在info.plist里加入

    <key>LSApplicationQueriesSchemes</key>

      <array>

      <string>weixin</string>

      <string>wechat</string>

      <string>sina</string>

      <string>weibo</string>

    </array>

    你也可以查看友盟分享SDK适配iOS9的文档:http://dev.umeng.com/social/ios/ios9

  • 相关阅读:
    第八次作业-非确定的自动机NFA确定化为DFA
    正规式到正规文法与自动机
    正则表达式基本介绍
    博客园源码不可copy的解决办法
    爬取湖北师范大学招生信息网中的专业简介
    利用爬虫爬取LOL官网上皮肤图片
    利用python的requests和BeautifulSoup库爬取小说网站内容
    python图像处理之PIL库
    Python之文件的使用
    python入门之jieba库的使用
  • 原文地址:https://www.cnblogs.com/fengmin/p/5484426.html
Copyright © 2011-2022 走看看