I need to catch errors that occur in WebView
if WebView
is present in the screen. That is not to bind to a specific WebView
.
WebView can be defined as an object which can display the interactive web content and load HTML strings within the iOS application for an in-app browser. It is an instance of the WKWebView class, which inherits the UIView class.
Debugging with WKWebViewOpen Safari and press ⌘+, to open Preference, under the Advanced tab, check “Show Develop menu in menu bar”. Not until we have the project build can we use the Safari debugger. The debugger is under Develop → Your simulator or device.
A WKWebView object is a platform-native view that you use to incorporate web content seamlessly into your app's UI. A web view supports a full web-browsing experience, and presents HTML, CSS, and JavaScript content alongside your app's native views.
Not sure if you have already tried this solution,You can catch the exception in your JS code and call a native method to log this information. You can inject this native method implementation into JS context of the UIWebview after a receiving below UIWebView delegate callback that JS context for the webView has been created.
- (void)webView:(id)webView didCreateJavaScriptContext:(JSContext *)context forFrame:(id)frame {
//this injects the MyNativeLog in your UIWebView JS context and you can call this function in your JS code.
context[@"MyNativeLog"] = ^(NSString *string){
NSLog(@"%@", string);
};
}
Hope this helps!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With