iOS9 Http Setup

Target

本篇主要的目的,是為了解決iOS9之後,
網路要求無法使用的問題。

Action Items

  1. Root cause
  2. Solution
  3. NSAppTransportSecurity

Quick Start

Root cause

Apple 在 iOS9 和 OS X v10.11版本中,
默認使用 App Transport Scurity (ATS),
網路必須使用 Https 傳輸,否則連線要求會被禁止。

Solution

  • Solution 1: 讓Server update to TLS2.0
    ps. 無法馬上完成,下次有機會再處理。
  • Solution 2: 在iOS中設定AppTransportSecurity
    ps. Apple 較不建議,可以馬上繼續使用。

以下就Solution 2 來做簡單設定教學:

Step 1: Open Xcode Porject

Step 2: TARGETS -> Info

Step 3: Custom iOS Target Properties

App Transport Security Settings

第一層
  • Key: App Transport Security Settings (Dictionary)
    第二層
  • Key: Allow Arbitrary Loads
  • Boolean: YES

NSAppTransportSecurity

以下為 iOS Developer Library 針對 NSAppTransportSecurity 的一些說明:

Specifies exceptions to the default strong Internet security in iOS and OS X apps and in app extensions

ATS employs the Transport Layer Security(TLS)
protocol version 1.2.

ATS is enforced by the NSURLSession class and all APIs that use it.

Reference

文章目录
  1. 1. Target
  2. 2. Action Items
  3. 3. Quick Start
    1. 3.1. Root cause
    2. 3.2. Solution
      1. 3.2.1. Step 1: Open Xcode Porject
      2. 3.2.2. Step 2: TARGETS -> Info
      3. 3.2.3. Step 3: Custom iOS Target Properties
        1. 3.2.3.1. 第一層
        2. 3.2.3.2. 第二層
    3. 3.3. NSAppTransportSecurity
  4. 4. Reference
,