iOS9 新特性

来源:互联网 发布:护理优化服务流程 编辑:程序博客网 时间:2024/05/16 11:26

iOS9新特征:

1.HTTP不能正常使用。

  iOS9引入了新特性App Transport Security (ATS)。


新特性要求App内访问的网络必须使用HTTPS协议。

但是现在公司的项目使用的是HTTP协议,使用私有加密方式保证数据安全。现在也不能马上改成HTTPS协议传输。


最终找到以下解决办法:


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


iOS 9 and OSX 10.11 require TLSv1.2 SSL for all hosts you plan to request data from unless you specify exception domains in your app's Info.plist file.

The syntax for the Info.plist configuration looks like this:

<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.1</string>

    </dict>

  </dict>

</dict>




Table 1-1Info.plist keys: Structure and types

Key

Type

NSAppTransportSecurity

Dictionary

    NSAllowsArbitraryLoads

Boolean

    NSExceptionDomains

Dictionary

        <domain-name-for-exception-as-string>

Dictionary

            NSExceptionMinimumTLSVersion

String

            NSExceptionRequiresForwardSecrecy

Boolean

            NSExceptionAllowsInsecureHTTPLoads

Boolean

            NSIncludesSubdomains

Boolean

            NSThirdPartyExceptionMinimumTLSVersion

String

            NSThirdPartyExceptionRequiresForwardSecrecy

Boolean

            NSThirdPartyExceptionAllowsInsecureHTTPLoads

Boolean



If your application (a third-party web browser, for instance) needs to connect to arbitrary hosts, you can configure it like this:

<key>NSAppTransportSecurity</key>

<dict>

    <!--Connect to anything (this is probably BAD)-->

    <key>NSAllowsArbitraryLoads</key>

    <true/>

</dict>





一个符合 ATS要求的 HTTPS,应该满足如下条件:

  1. Transport Layer Security协议版本要求TLS1.2以上
  2. 服务的Ciphers配置要求支持Forward Secrecy
  3. 证书签名算法符合ATS要求等


Privacy and Your AppURL scheme changes


也就是说:在iOS9中,如果使用canOpenURL:方法,该方法所涉及到的URL scheme必须在"Info.plist"中将它们列为白名单(白名单上限是50个),否则不能使用。key叫做LSApplicationQueriesSchemes,键值内容是:



iOS9openURL:方法没有什么实质性的变化,仅仅多了一个提示框。


常见 URL Scheme

如果想一次性集成最常用的微信、新浪微博、QQ、支付宝四者的白名单,则配置如下:

 <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>


    <!-- QQQzone 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>


    <!--支付宝  URL Scheme白名单-->

    <string>alipay</string>

    <string>alipayshare</string>


</array>



其他问题:




iOS9新特性_更灵活的后台定位

同一App中的多个location manager:一些只能在前台定位,另一些可在后台定位,并可随时开启或者关闭特定location manager的后台定位。

(1)添加代码

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9) {

    _locationManager.allowsBackgroundLocationUpdates = YES;

}

(2)plist里面添加key




Bitcode

bitcode 是被编译程序的一种中间形式的代码。包含 bitcode配置的程序将会在 App Store上被编译和链接。 bitcode允许苹果在后期重新优化我们程序的二进制文件,而不需要我们重新提交一个新的版本到 App Store上。

当我们提交程序到 App Store上时, Xcode会将程序编译为一个中间表现形式( bitcode )。然后 App store 会再将这个 bitcode编译为可执行的64位或32位程序。


Watch 应用必须包含 bitcodeiOS不强制,Mac OS不支持。但是Xcode7及以上版本会默认开启 bitcode



开发者都知道,当前 iOS App的编译打包方式是把适配兼容多个设备的执行文件及资源文件合并一个文件,上传和下载的文件则包含了所有的这些文件,导致占用较多的存储空间。

App Thinning是一个关于节省iOS设备存储空间的功能,它可以让iOS设备在安装、更新及运行App等场景中仅下载所需的资源,减少App的占用空间,从而节省设备的存储空间。


根据Apple官方文档的介绍,App Thinning主要有三个机制:

  1. Slicing
    开发者把App安装包上传到AppStore后,Apple服务会自动对安装包切割为不同的应用变体(App variant),当用户下载安装包时,系统会根据设备型号下载安装对应的单个应用变体。
  2. On-Demand Resources
    ORD(
    随需资源)是指开发者对资源添加标签上传后,系统会根据App运行的情况,动态下载并加载所需资源,而在存储空间不足时,自动删除这类资源。
  3. Bitcode开启Bitcode编译后,可以使得开发者上传App时只需上传Intermediate Representation(中间件),而非最终的可执行二进制文件。在用户下载App之前,AppStore会自动编译中间件,产生设备所需的执行文件供用户下载安装。



如果你的应用也准备启用 Bitcode编译机制,就需要注意以下几点:

  1. Xcode 7默认开启 Bitcode,如果应用开启 Bitcode,那么其集成的其他第三方库也需要是 Bitcode 编译的包才能真正进行 Bitcode编译
  2. 开启 Bitcode编译后,编译产生的.app体积会变大(中间代码,不是用户下载的包),且.dSYM文件不能用来崩溃日志的符号化(用户下载的包是 Apple服务重新编译产生的,有产生新的符号文件)
  3. 通过 Archive方式上传 AppStore的包,可以在XcodeOrganizer工具中下载对应安装包的新的符号文件



关闭Bitcode



0 0
原创粉丝点击