我使用的客户端与在 iOS 8.4 中使用的客户端相同,但客户端在 iOS 9 中无法运行。
相同的代码在 iOS 8.4 中有效,但在 iOS 9 中无效,我不知道,但奇怪的是我的应用程序停止工作。
从 iOS 9 开始,我们必须在我正在设置的 info.plist 中设置安全密钥,但客户端仍然无法正常工作。
我收到以下错误:
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: unauthorized (401)" UserInfo={com.alamofire.serialization.response.error.response= { URL: https://api.xing.com/v1/request_token } { status code: 401, headers {
"Cache-Control" = "no-cache";
Connection = "Keep-Alive";
"Content-Encoding" = gzip;
"Content-Length" = 93;
"Content-Type" = "application/json; charset=utf-8";
Date = "Tue, 01 Sep 2015 06:29:16 GMT";
"Keep-Alive" = "timeout=5, max=56";
Server = Apache;
"Set-Cookie" = "c_=baca882ff97bd2cf6a18b395933613a0; domain=.xing.com; path=/; expires=Mon, 27 Aug 2035 06:29:16 -0000; secure; HttpOnly";
Status = "401 Unauthorized";
Vary = "Accept-Encoding";
"X-Content-Type-Options" = nosniff;
"X-Frame-Options" = SAMEORIGIN;
"X-Logjam-Request-Action" = "WebService::OauthController#request_token";
"X-Logjam-Request-Id" = "xws-production-85b5a502132e496daedb58968863026a";
"X-Powered-By" = "Phusion Passenger 4.0.59";
"X-Request-Id" = "e82a4a5e-5876-4e1d-9017-85dbbbd1a0f4";
"X-Runtime" = "0.012464";
"X-XSS-Protection" = "1; mode=block";
} }, NSErrorFailingURLKey=https://api.xing.com/v1/request_token, com.alamofire.serialization.response.error.data=<7b226d65 73736167 65223a22 496e7661 6c696420 4f417574 68207369 676e6174 75726522 2c226572 726f725f 6e616d65 223a2249 4e56414c 49445f4f 41555448 5f534947 4e415455 5245227d>, NSLocalizedDescription=Request failed: unauthorized (401)}
我在 info.plist 中添加了以下代码:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
我使用来自以下 URL 的引用代码: