The OSInAppBrowserLib-iOS
is a library built using Swift
that provides a web browser view to load a web page within a Mobile Application. It behaves as a standard web browser and is useful to load untrusted content without risking your application's security.
The OSIABEngine
structure provides the main features of the Library, which are 3 different ways to open a URL:
- using an External Browser;
- using a System Browser;
- using a Web View.
Each is detailed in the following sections.
This library is to be used by the InAppBrowser Plugin for OutSystems' Cordova Plugin and Ionic's Capacitor Plugin.
The repository contains a build_framework.sh
script that allows the creation of the OSInAppBrowserLib.xcframework
. This framework should then be imported into its callers as a framework.
- Create the
OSInAppBrowserLib.xcframework
using thebuild_framework.sh
script. This is achievable through the following bash script.
sh build_framework.sh
- Include the
OSInAppBrowserLib.xcframework
on your project. For example, the following must be inserted into theplugin.xml
to achieve this on a Cordova plugin.
<framework src="{path to framework}/OSInAppBrowserLib.xcframework" embed="true" custom="true" />
As mentioned before, the library offers the OSIABEngine
structure that provides the following methods to interact with:
func openExternalBrowser(_ url: URL, routerDelegate: ExternalBrowser, _ completionHandler: @escaping (ExternalBrowser.ReturnType) -> Void)
Uses the parameter routerDelegate
- an object that offers an External Browser interface - to open the parameter url
. The method is composed of the following input parameters:
- url: the URL for the web page to be opened.
- routerDelegate: The External Browser interface that will open the URL. Its return type should be
Bool
. The library provides anOSIABApplicationRouterAdapter
class that allows a class that implementsOSIABApplicationDelegate
(likeUIApplication
, that uses the device's default browser) to open it. - completionHandler: The callback with the result of opening the URL with the External Browser interface.
func openSystemBrowser(_ url: URL, routerDelegate: SystemBrowser, _ completionHandler: @escaping (SystemBrowser.ReturnType) -> Void)
Uses the parameter routerDelegate
- an object that offers a System Browser interface - to open the parameter url
. The method is composed of the following input parameters:
- url: the URL for the web page to be opened.
- routerDelegate: The System Browser interface that will open the URL. Its return type should be
UIViewController
or a subclass. The library provides anOSIABSafariViewControllerRouterAdapter
class that usesSFSafariViewController
to open it. - completionHandler: The callback with the result of opening the URL with the System Browser interface.
func openWebView(_ url: URL, routerDelegate: WebView, _ completionHandler: @escaping (WebView.ReturnType) -> Void)
Uses the parameter routerDelegate
- an object that offers a Web View interface - to open the parameter url
. The method is composed of the following input parameters:
- url: the URL for the web page to be opened.
- routerDelegate: The Web View interface that will open the URL. Its return type should be
UIViewController
or a subclass. The library provides anOSIABWebViewRouterAdapter
class that usesWKWebView
to open it. - completionHandler: The callback with the result of opening the URL with the Web View interface.