Start a Project

WKWebview trigger native function in Swift

As you all know the UIWebview is deprecated in the iOS 8.0 and above versions. So we have to use WKWebview to show URLs and other data. WKWebview is an object that displays interactive web content, such as for an in-app browser.

Example:

To add observers you need to insert javascript into the webpage or you can also insert this at the server-side. In the below code the source is depended on the need i.e. on which button or task you have to perform the action. Here we have added the script that runs on the click of any button.

When you have inserted the script into the webpage then you need to handle the messageHandlers.

You can know more about WKWebview from here.

Thank you!!!

Exit mobile version