gpt4 book ai didi

javascript - react 原生 : Get internal api call data from url of the WebView

转载 作者:行者123 更新时间:2023-12-04 11:36:24 24 4
gpt4 key购买 nike

我有一个带有 url 的 webview(例如支付处理页面)。加载 url 后,某些 api 调用已完成,我想知道如何从该特定 url 的内部 api 调用中获取数据。

它不像网页和 react 原生代码之间的通信。 ( window.ReactNativeWebView.postMessageonMessage )
我需要来自网页的内部 api 调用响应数据。

最佳答案

解决方案1:
您可以将 js 注入(inject) webview 以获取 api 详细信息

var open = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
this.addEventListener("load", function() {
var message = {"status" : this.status, "responseURL" : this.responseURL}
webkit.messageHandlers.handler.postMessage(message);
});
open.apply(this, arguments);
};
解决方案2:
目前,没有办法拦截 webview 内部 API 调用。
您可以在 webview 中添加对此的支持
安卓
在android中你必须使用 WebViewClient.shouldInterceptRequest()您可以添加桥接方法 REF

关于javascript - react 原生 : Get internal api call data from url of the WebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60620388/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com