Sample Project: An iOS Dedicated WebKit Web Browser in Swift

Within our own native iOS application it may be desirable or necessary to display content that is already being hosted on our website. Displaying our already existing Privacy Policy or Terms of Service agreement content is one example. A reasonable user experience would allow them to navigate our web content but prevent them from straying to external websites or other parts of our website. 

Dedicated Web Browser


This sample project instantiates an Apple's WKWebView class and uses it as the backbone of our dedicated web browser. This class comes equipped with a delegate, WKNavigationDelegate,  protocol that we interface with for the purpose of controlling where the user navigates too. We also use Key Value Observing (KVO) to listen in on changes to the browser's forward and backward history to toggle the availability of those buttons and the estimated progress to finish when content is loading and a separate content loading Boolean flag to control whether the progress bar is visible or not. This project also displays an alert message if the user attempts to stray from our site's root domain.

This project can be found on GitHub.

No comments:

Post a Comment