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.
Replace
${version to use}below with the version you want to use. Check the Releases page for available versions.
The library is also available as a Swift Package. Add the following to your Package.swift file:
dependencies: [
.package(url: "https://github.com/OutSystems/OSInAppBrowserLib-iOS.git", from: "${version to use}")
]The library is available on CocoaPods as OSInAppBrowserLib. The following is an example of how to insert it into a Cordova plugin (through the plugin.xml file).
<podspec>
<config>
<source url="https://cdn.cocoapods.org/"/>
</config>
<pods use-frameworks="true">
...
<pod name="OSInAppBrowserLib" spec="${version to use}" />
...
</pods>
</podspec>It can also be included as a dependency on other podspecs.
Pod::Spec.new do |s|
...
s.dependency 'OSInAppBrowserLib', '${version to use}'
...
endAs 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. - 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
UIViewControlleror a subclass. The library provides anOSIABSafariViewControllerRouterAdapterclass that usesSFSafariViewControllerto 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
UIViewControlleror a subclass. The library provides anOSIABWebViewRouterAdapterclass that usesWKWebViewto open it. - completionHandler: The callback with the result of opening the URL with the Web View interface.