Closed wjiuxing closed 4 years ago
你是什么场景下,需要同步的?
H5 那边需要等到结果才执行后面的代码,无法推动他们改成异步回调的方式。改变不了别人,只能 改变自己了。。。
发自Jiuxing Wang's iPhone
在 2020年7月23日,下午6:41,Karosli notifications@github.com 写道:
你是什么场景下,需要同步的?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/karosLi/KKJSBridge/pull/31#issuecomment-662937132, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA73W2F6IMU7ATNES3S5SA3R5AHXFANCNFSM4O7VQD4Q.
那让H5自己封装成 promise,或者你这边注入js,提供promise的方法
好的,我去请 h5 搞一下,谢谢了!
通过原生的
window.webkit.messageHandlers
来postMessage
的方式是异步的,有时候 JS 端也需要同步交互。在此次 PR 中借助
webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:
的特性,实现了同步交互。用法如下: