Copy link to clipboard
Copied
Hi,
I have an application on Appstore like 2 years.
On iOS10 my app not working. Cant 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
Please help me to solve this problem.
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);
Hi Efe,
I tried running the sample fla project that you shared with me on DropBox.
We investigated it further and figured out that your app.xml file doesn't contain the below tags that is required to allow streaming of http URL's on iOS:
Please add below tags under <InfoAdditions> tag
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
I tested it at my end and now it works fine both on iOS9 and iOS 10.
Thanks,
Adobe AIR Team
Copy link to clipboard
Copied
Hi Efe,
I made some changes in your code snippet and running it both on iOS 9 and iOS 10. Please refer to below code snippet:
public class URLLoader_loadExample extends Sprite {
public var loader:URLLoader;
public function URLLoader_loadExample() {
loader = new URLLoader();
configureListeners(loader);
var request:URLRequest;
request = new URLRequest("http://api.website.net/check.php");
request.method = URLRequestMethod.POST;
var urlVars:URLVariables = new URLVariables();
//urlVars.user_id = Main.instance.userID;
request.data = urlVars;
try {
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.load(request);
} catch (error:Error) {
trace("Unable to load requested document.");
}
}
private function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
private function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
trace("completeHandler: ");
trace(event.target.data);
}
You are using URLLoaderDataFormat.VARIABLES that requires name/values pair to be returned from your php file. When I changed it to loader.dataFormat = URLLoaderDataFormat.TEXT; it works fine both on iOS 9 and iOS 10 and successfully getting completed without any error.
Thanks,
Adobe AIR Team
Copy link to clipboard
Copied
I think i tested on simulator only.
Not working on ios10
Copy link to clipboard
Copied
I found errors about server requirements.
Found a https link to try and that work. But my http link not working.
Some forums says iPv6 must supported on your server.
Do you know which requirements need to work with iOS10?
Copy link to clipboard
Copied
Hi Efe,
I tried running the sample fla project that you shared with me on DropBox.
We investigated it further and figured out that your app.xml file doesn't contain the below tags that is required to allow streaming of http URL's on iOS:
Please add below tags under <InfoAdditions> tag
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
I tested it at my end and now it works fine both on iOS9 and iOS 10.
Thanks,
Adobe AIR Team
Copy link to clipboard
Copied
Wow... now it works
Thank you so much
Copy link to clipboard
Copied
Adobe staff really shouldn't keep posting
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
as *the* solution for every NSAppTransportSecurity issue.
The proper solution is to only add exceptions to the domains your app is really using, not just completely disable NSAppTransportSecurity like this. This isn't why Apple added this feature just so everyone turns around and just disables it.
Completely disabling NSAppTransportSecurity should only be used in development testing or if your app actually needs to allow your users to enter arbitrary URLs like a web browser. At some point Apple will likely crack down on settings like the above when you submit to the store (if they aren't already)
Copy link to clipboard
Copied
Hi Jeffery,
We completely agree with you on the fact that we shouldn't be telling users to completely disable this security restriction. We have taken a note of this and we will be specific going forward.
Thank you so much.
-Ankit
Adobe Air Team