Is it possible to share AFNetworking session with UIWebView? I used AFNetworking to login to remote server, but the UIWebView have no idea about the session being created by AFNetworking?
Sharing session between AFNetworking and UIWebView
1.2k Views Asked by RyanB At
2
There are 2 best solutions below
0
On
Try using the UIWebView+AFNetworking category's to call loadRequest.
http://cocoadocs.org/docsets/AFNetworking/3.1.0/Categories/UIWebView+AFNetworking.html
Actually,
AFNetworkingandUIWebViewshare the same cookies storage. So we don't need any special technique to letUIWebView"share" a session initialized byAFNetworking, or any native session-based request which usesNSHTTPCookieStorageto store cookie. In my situation, theUIWebViewdid not find shared session to be useful, just because the session initialized byAFNetworkinghas lacked of a cookie which was sent only when browsing the site with a browser.And here is what I did to solve the problem:
Above code will ensure that we have all browser-specific cookies in NSHTTPCookieStorage, hence let the
UIWebViewshare any session initialized by native login routine.