Search code examples
actionscript-3airadobeios10animate-cc

Adobe Air Can't Connect to Server on iOS10


I have an application on Appstore like 2 years. I developed with Adobe AIR.

On iOS10 my app not working. Can't connect to http links.

I debug and get error from connections: Error #2044: Unhandled ioError:. text=Error #2032: Stream Error. URL: http://api.website.net/check.php

I used HTTPStatusEvent.HTTP_STATUS for understand any solution, it gives 0

Any methods to solve?

MY CODE:

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

Solution

  • Sounds like it's related to the iOS App Transport security settings.

    To enable http requests you will need to either define the domains as exceptions in your application descriptor:

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

    or add a global ignore security setting:

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

    These settings should be added to the InfoAdditions node in your iPhone settings of your application descriptor:

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