unleashedspeed / JavaScript-iOS

iOS App invoking JavaScript from native Swift code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JavaScript-iOS

This project is a test project that invokes JavaScript from native Swift code. WKWebKit is used to invoke JavaScript. Initially JavaScript is loaded from a web url in String form and evaluated using WKWebView instance. Operation enum represents a single operation which will be created using JS function startOperation. 4 different operations are created and 4 different progress UI elements are used to represent each operation. Progress UI elements are custom UIView's (HorizontalProgressBar and CircularProgressBar). A MessageHandler (jumbo here) is added to WKWebViewConfiguration's userContentController which receives the messages posted on the handler through WKScriptMessageHandler's delegate method didReceive. Upon receiving a new message, it is identified which operation this message belongs to and that operation's UI progress is updated accordingly using handleMessage (inside VaccineTrialViewController).

Unit Tests

There are 4 unit tests added JavaScriptTests

Operations in progress

Screenshot 2020-09-03 at 9 29 50 PM

Operations finished successfully or finished with error

Screenshot 2020-09-03 at 11 05 05 PM

Exception Handling

Screenshot 2020-09-03 at 9 21 34 PM

About

iOS App invoking JavaScript from native Swift code.


Languages

Language:Swift 100.0%