Has anyone figured out if they can utilize the UIWebView via an ANE? I don't simply want to display things (like StageWebView), I want to use the lower level functions.
What I ultimately would like to do is send the UIWebView an URL to submit a form via "POST" to which will in turn give me back cookies. The same as if you visit a login form, fill in username/password and hit submit. After that a few cookies are assigned to me. I need to trap and use these cookies to make more requests.
My desire is to use UIWebView to download files. Currently I've already done it easily (natively) with a cookie collection. I can submit the post, capture the cookies and then send a direct url request (supplying those vital cookies). After that the server sends me a file.
This is a basic login setup. You must log in first. The system sets cookies (a login cookie and a session id). I supply those cookies to any further requests for "files" (PDFs, XLS, DOC, MP3, etc) and it allows me to directly download these files.
Has anyone figured out if ANE supports using the UIWebView in such a way?
I know the general rule is anything visual is off limits to ANE. I hope UIWebView can be used "non-visually" so I can trap those cookies to be able to download files. The purpose of the app is to download files once logged in.
Thanks for any tips in this
First of all, I just want to make sure I understand your question correctly. So, you want to make a request, then get a response, which is a cookie, parse the cookie, and get the user and session information for further request.
Objective-C can access cookie object after you send the request. quotes from a post in stackoverflow: "The URL loading system automatically sends any stored cookies appropriate for an NSURLRequest. unless the request specifies not to send cookies. Likewise, cookies returned in an NSURLResponse are accepted in accordance with the current cookie acceptance policy."
if you use NSURLRequest to send out the request, you should be able to manipulate the cookie objects easily.
Afterwards, when the UIWebview extension initialized, you get the cookie object, have the user and session information stored locally, to make a function call from Flex for "files" should be fine then.
I guess stageWebView doesn't have the access to request cookie, does it? If it can, go for it, and it should be much simpler.
I've seen no methods that let you do much more than set or sense the change in location of a StageWebView unfortunately. There was an extension StageWebViewBridge by Pedro that let AS and JS talk so I could read the cookies and send them back to as.
What i need to do, specifically, is download files. But if I don't include 2 cookies on my request, the file will be denied. I'm looking for the closest point from A to B.
I think you can do that via UIWebview native extension since the objective-c side can handle the cookie. You probably need some of those steps:
A function that takes in parameter from Flex to objective call get the cookie, then store the user and session information locally. dispatch the information back to Flex if need.
A function triggers from Flex to download files with local user and session information. dispatch status event to Flex.
A function to deal with downloaded files.
Regarding the files that you download, displaying through UIWebview is straigtforward. If you want to store in the ipad or do something else, that's another story, but I think they are all possible.
I'm trying to download files. These files require 2 cookies to be present in the request. You get the 2 cookies by POSTing a username/password combo to an URL. That URL performs a few redirects and over the redirects some cookies are issued. 2 to be exact. Currently in with obj-c or c#.NET I capture the cookies, supply them in future requests and it works perfectly fine.
Now I'm trying to continue down the Adobe path in making this app.
I have noticed that cookies are maintained between redirects can be followed via the URLRequest method and some AIR properties. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fla sh/net/URLRequest.html So I set manageCookies and followRedirects to true. Apparently if I keep using the same URLLoader and the same URLRequest simply changing the .url property the cookie continues to exist. So I can actually download files using URLLoader!
I had no idea that was possible. I've successfully downloaded several files so far, nothing too big though. I do find if I download in anything other than binary it fails (like XML). No matter, keep it on binary and it works fine. Just incase anyone else is looking to do that.
There is an ANE for UIWebView, guess it might help. http://darkredz.com/introducing-ios-uiwebview-and-videoplayer-native-e xtension-for-air-mobile/
Interesting ANE overall but unfortunately not for my purposes. I need to capture cookies which is a pretty low level task. I've even created a pure TCP HTTP parser and sent requests directly to servers while capturing cookies for subsequent requests that works fine, except AIR for mobile doesn't support TCP (I found out later, doh).
This project is on hold at the moment but once I come up with a solid solution I'll post back.