2
votes

I have an application that may access authenticated content. I know that the webview can't handle authentication so I do some NSConnection magic to make it work (something similar to this)

The thing is that there is some content that can be accessible using this web view, but there is some other content that event after a sucessfull authentication, the web view is not able to load.

BUT.. if I enter the same url with mobile safari, enter the needed credentials and then I go back to my app, the WebView seems to load the content fine.

I tried reviewing the cookies before and after the auth in Safari is done using this code

[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];

and the cookies are the same.

As far as I understand that code will retrieve the cookies my app generates and not the ones available in iOS, so apparently this is not the way to look for a hint...

Any ideas?

3

3 Answers

4
votes

Recently, i've lurked for the same question over the internet, and the answer is "no" =(. Objects of UIWebView class and Safari or other browsers live apart and are sandboxed. Here is official position about cookies.

0
votes

TO the best of my understanding, Cookies can not be sent with the first request from a Webview, but can be sent with subsequent requests to the same URL, if and only if, the first request was successful.

This causes problems with authentication services that require cookies to authenticate on the first request to the URL.

-1
votes

Possibly user credentials are stored via keychain api. Keychain is shared between apps, so stored login/pass in Safari can appear in your app UIWebView.Can you elaborate this as i also need this.