WKWebView 서로 간에 Cookie 공유하는 방법.

iOS 8 이상 부터 사용할 수 있는 WKWebView는 UIWebView와 다르게 서로 다른 인스턴스 간에 쿠키가 공유되지 않는다.

쿠키를 서로 공유하게 하기 위해선 서로 같은 WKProcessPool을 사용하게 하면 된다.

self.processPool = WKProcessPool()

let configuration1: WKWebViewConfiguration = WKWebViewConfiguration()
configuration1.processPool = self.processPool

let webView1: WKWebView = WKWebView(frame: CGRectZero, configuration: configuration)

let configuration2: WKWebViewConfiguration = WKWebViewConfiguration()
configuration1.processPool = self.processPool

let webView2: WKWebView = WKWebView(frame: CGRectZero, configuration: configuration)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s