3

There is a controller with a WKWebView "Parent" that opens (pushes) another controller with another WKWebView "Child".

When Child modifies the localStorage, sessionStorage or IndexedDB then pops back to Parent, Parent is NOT aware of the changes and needs to be reloaded to see the new values set by Child.

It means that both WKWebView share the same localStorage, sessionStorage, indexedDB, but they need a refresh of the content to see the modifications.

How to share in real-time the same storage between WKWebView?

1 Answer 1

8

The init of WKWebViews can receive a parameter WKWebViewConfiguration with a variable called processPool that represents all the web content (including localStorage, IndexedDB, cookies and so on) process.

So for the WKWebViews to share in real-time all the memory management, you need to declare a unique WKProcessPool for all of them.

let uniqueProcessPool = WKProcessPool()

let configA = WKWebViewConfiguration()
configA.processPool = uniqueProcessPool
let webViewA = init(frame: CGRect.zero, configuration: configA)

let configB = WKWebViewConfiguration()
configB.processPool = uniqueProcessPool
let webViewB = init(frame: CGRect.zero, configuration: configB)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.