JavaScript synchronous native communication to WKWebView

前端 未结 4 541
我在风中等你
我在风中等你 2020-11-29 23:21

Is synchronous communication between JavaScript and Swift/Obj-C native code possible using the WKWebView?

These are the approaches I have tried and have failed.

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 23:58

    No I don't believe it is possible due to the multi-process architecture of WKWebView. WKWebView runs in the same process as your application but it communicates with WebKit which runs in its own process (Introducing the Modern WebKit API). The JavaScript code will be running in the WebKit process. So essentially you are asking to have synchronous communication between two different processes which goes against their design.

提交回复
热议问题