Reputation: 1865
I have a webview with a url (for example a payment processing page). When the url is loaded, certain api calls are done and i want to know how to get data from the internal api calls of that particular url.
It is not something like communication between webpage and react native code. ( window.ReactNativeWebView.postMessage
or onMessage
)
I need internal api call response data from the webpage.
Upvotes: 6
Views: 3194
Reputation: 17953
I think you can inspect/log the network requests by setting up a (WiFi) proxy:
Upvotes: 0
Reputation: 25423
you can inject js into webview to get api detail
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);
};
right now, there is no way to intercept webview internal API calls.
you can add support for this in webview
In android you have to use
WebViewClient.shouldInterceptRequest()
you can add bridging method REF
Upvotes: 4