Skip to main content
sinious
Legend
April 20, 2012
Question

AIR for iOS ANEs, I'd like to use UIWebView..

  • April 20, 2012
  • 6 replies
  • 3679 views

Hi all,

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

This topic has been closed for replies.

6 replies

Inspiring
April 20, 2012

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.

Regards,

Matthew

sinious
siniousAuthor
Legend
April 22, 2012

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.

Inspiring
April 23, 2012

Hi, sinious:

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:

UIWebview initialization.

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.

Good luck!