0

我在 Appstore 上申请了 2 年。我使用 Adob​​e AIR 进行开发。

在 iOS10 上,我的应用程序无法正常工作。无法连接到 http 链接。

我调试并从连接中获取错误:错误#2044:未处理的ioError:。文本=错误 #2032:流错误。网址:http ://api.website.net/check.php

我使用 HTTPStatusEvent.HTTP_STATUS 来理解任何解决方案,它给出了 0

有什么方法可以解决?

我的代码:

var urlReq:URLRequest = new URLRequest ("http://api.website.net/check.php");            
urlReq.method = URLRequestMethod.POST;          
var urlVars:URLVariables = new URLVariables();          
urlVars.user_id = Main.instance.userID;     
urlReq.data = urlVars; 


var loader:URLLoader = new URLLoader (urlReq);
loader.addEventListener(Event.COMPLETE, onCreditComplete);


loader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, httpStatusHandler);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);


loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load(urlReq);
4

1 回答 1

5

听起来它与 iOS App Transport 安全设置有关。

要启用http请求,您需要在应用程序描述符中将域定义为异常:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>api.website.net</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSIncludesSubdomains</key>
            <true/>
        </dict>
    </dict>
</dict>

或添加全局忽略安全设置:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

这些设置应添加到InfoAdditions应用程序描述符的 iPhone 设置中的节点:

<iPhone>
    <InfoAdditions><![CDATA[
        <key>UIDeviceFamily</key>
        <array>
            <string>1</string>
            <string>2</string>
        </array>

        <!-- Add the above settings here -->

    ]]></InfoAdditions>
    <requestedDisplayResolution>high</requestedDisplayResolution>
    <Entitlements>
        <![CDATA[
        ]]>
    </Entitlements>
</iPhone>
于 2016-09-28T10:17:02.013 回答