Skip to content

OutSystems-owned repository for the InAppBrowser plugin's iOS library.

License

Notifications You must be signed in to change notification settings

OutSystems/OSInAppBrowserLib-iOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OSInAppBrowserLib

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.

Index

Motivation

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.

Usage

  1. Create the OSInAppBrowserLib.xcframework using the build_framework.sh script. This is achievable through the following bash script.
sh build_framework.sh
  1. Include the OSInAppBrowserLib.xcframework on your project. For example, the following must be inserted into the plugin.xml to achieve this on a Cordova plugin.
<framework src="{path to framework}/OSInAppBrowserLib.xcframework" embed="true" custom="true" />

Methods

As mentioned before, the library offers the OSIABEngine structure that provides the following methods to interact with:

Open a URL in an External Browser

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 an OSIABApplicationRouterAdapter class that allows a class that implements OSIABApplicationDelegate (like UIApplication, 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.

Open a URL in a System Browser

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 an OSIABSafariViewControllerRouterAdapter class that uses SFSafariViewController to open it.
  • completionHandler: The callback with the result of opening the URL with the System Browser interface.

Open a URL in a Web View

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 an OSIABWebViewRouterAdapter class that uses WKWebView to open it.
  • completionHandler: The callback with the result of opening the URL with the Web View interface.