Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/outsystems/osinappbrowserlib-ios
OutSystems-owned repository for the InAppBrowser plugin's iOS library.
https://github.com/outsystems/osinappbrowserlib-ios
snyk-mobile
Last synced: 4 days ago
JSON representation
OutSystems-owned repository for the InAppBrowser plugin's iOS library.
- Host: GitHub
- URL: https://github.com/outsystems/osinappbrowserlib-ios
- Owner: OutSystems
- License: mit
- Created: 2024-05-21T10:46:58.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-08-20T09:30:09.000Z (5 months ago)
- Last Synced: 2024-11-15T09:52:01.861Z (about 2 months ago)
- Topics: snyk-mobile
- Language: Swift
- Size: 3.97 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# 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](#motivation)
- [Usage](#usage)
- [Methods](#methods)
- [Open a URL in an External Browser](#open-a-url-in-an-external-browser)
- [Open a URL in a System Browser](#open-a-url-in-a-system-browser)
- [Open a URL in a Web View](#open-a-url-in-a-web-view)## Motivation
This library is to be used by the InAppBrowser Plugin for [OutSystems' Cordova Plugin](https://github.com/OutSystems/cordova-outsystems-inappbrowser) and [Ionic's Capacitor Plugin](https://github.com/ionic-team/capacitor-os-inappbrowser).
## Usage
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).
```xml
...
...
```
It can also be included as a dependency on other podspecs.
```ruby
Pod::Spec.new do |s|
...
s.dependency 'OSInAppBrowserLib', '${version to use}'
...
end
```## 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
```swift
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
```swift
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
```swift
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.