Calling Swift function from JavaScript and JS function from Swift

When we develop a web app for iOS devices, we need to know how to call JavaScript function from Swift and also how to call Swift function from JavaScript.

Here let me bring you full codes for ViewController.swift and the html file that I loaded it locally.

ViewController.swift

index.html

And here is the html file

URL Schemes

Another thing that you must configure is URL Schemes. Look what I’ve set here:

Do you like this post? Consider a donation 😀

Published by

Habibie

Habibie is an Indonesian freelance frontend-backend web programmer and cross platform mobile app developer. He's also good at graphics design, video editing, visual effects and animation.

Leave a Reply

Your email address will not be published. Required fields are marked *