Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window.prompt("KKJSBridge", messageString)不触发UIDelegate回调方法 #64

Open
FoneG opened this issue Mar 25, 2021 · 4 comments
Open

Comments

@FoneG
Copy link

FoneG commented Mar 25, 2021

为了实现webView和navtive埋点数据的同步,我们把page数据放到了cookie中给前端去读取。 前端读取cookie的时候(html、样式、脚本等静态资源加载完成,脚本文件开始解析执行),发现 window.prompt("KKJSBridge", messageString) 返回的response为null。打断点后发现prompt并没有触发UIDelegate的代理方法。

      KKJSBridge.prototype.syncCall = function (module, method, data) {
          function call() {
              var message = xxx
              var messageString = JSON.stringify(message);
              var response = window.prompt("KKJSBridge", messageString);
              return response ? JSON.parse(response) : null;
          }
           xxx
     };
@wjiuxing
Copy link
Contributor

弱弱地问一句,你是想走同步 JS 交互接口,还是想弹个框?

@FoneG
Copy link
Author

FoneG commented Mar 26, 2021

弱弱地问一句,你是想走同步 JS 交互接口,还是想弹个框?

就是想获取cookie信息,用的 'KKJSBridge/AjaxProtocolHook'

@karosLi
Copy link
Owner

karosLi commented Apr 2, 2021

image
需要在自己自定义的 webview 代理里实现如下代码

@FoneG
Copy link
Author

FoneG commented Apr 13, 2021

需要在自己自定义的 webview 代理里实现如下代码

已经实现了上面的代码,并且【不触发UIDelegate回调方法】的情形只在打开第一个webView的情况下才会出现,打开第二个webView就能正常走UIDelegate回调逻辑。

因为读取行为也是通过脚本自动执行的,推测可能跟js注入有关。目前临时方案是取消webView的预热,可以解决问题。但后面不知道该如何进一步分析,找出原因

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants