> For the complete documentation index, see [llms.txt](https://dev-en.omnione.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev-en.omnione.net/sdk-instruction-guide/untitled/ios.md).

# IOS

## 1. Framework import

Copies the OmniLinkframewrok in the target App directory.

![](https://1805733871-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MA9R5J-GVsSkFxuIMzv%2F-MEztQPgn1hr9YUuyeN1%2F-MEztvyrB5YSxSUExP8m%2Fimage.png?alt=media\&token=28bca193-2fbf-43e6-b667-7c9e573eb280)

Next, import the library to Embed & Sign that is in Project setting - General - Frameworks, Libraries, and Embedded Content.

![](https://1805733871-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MA9R5J-GVsSkFxuIMzv%2F-MEztQPgn1hr9YUuyeN1%2F-MEzty3wQjXlmHGrXj8f%2Fimage.png?alt=media\&token=a274784c-a077-4906-b90f-8f870c63594c)

## 2. Universal Link Settings

Run an App with the Universal Link method in an iOS 9 or above environment. For details regarding the Universal Link please check the developer site (<https://developer.apple.com/ios/universal-links/>).

### 2.1 apple-app-site-association&#x20;

Requires a Trusted SSL applied domain in order to support the Universal Link. And position it on "URL root/apple-app-site-association" or "URL root/.well-known/apple-app-site-association" by creating a file that has no accessible "apple-app-site-association" extension in that domain. (Ex: <https://cloud.raonmobilesecurity.com/.well-known/apple-app-site-association>)

Enter the file with the text editor below.

```
{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "Z4BS3F3UYR.com.raonsecure.rsbridge.sample.ios",
                "paths": [
                    "/resources/rswta/appfree.jsp"
                ]
            }
        ]
    }
}
```

"paths" from the above contents is an address which corresponds to universalLink defined on Javascript RSBridge.conf.js. Moreover, "appID" is composited with "#Prefix.#BundleID#" and please check below for more details.

### 2.2 Apple Developer&#x20;

Activate "Associated Domains" as shown below in the target App on a App IDs(<https://developer.apple.com/account/ios/identifier/bundle>) of the Developer site.

Prefix and BundleID can be checked&#x20;

![](https://1805733871-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MA9R5J-GVsSkFxuIMzv%2F-MF-PCOlF_3Sdp5YlV7-%2F-MF-T1f_kfRAumb1ELQQ%2Fimage.png?alt=media\&token=44b8b2f9-abff-4cc3-96f8-44002ed0ce46)

### 2.3 Project setting

Activate the Associated Domains function in the Capabilities in project settings in the Xcode. Click the below + button to enter URL to apply to the Universal Link (ex:  applinks:#DomainName#)

![](https://1805733871-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MA9R5J-GVsSkFxuIMzv%2F-MF-PCOlF_3Sdp5YlV7-%2F-MF-T9M5mghNBoxXmYp8%2Fimage.png?alt=media\&token=c2c9a874-2120-4583-b545-44c69e3e4346)

When processing without any error, it will automatically create the entitlements file as below.

![](https://1805733871-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MA9R5J-GVsSkFxuIMzv%2F-MF-PCOlF_3Sdp5YlV7-%2F-MF-TCQ3YhOVFkfO8aQ0%2Fimage.png?alt=media\&token=ee6adc67-fcdb-4b5c-92f8-a47786878103)

## 3. Callback Browser Scheme setting

In order to go back from the Receive App to the Send App or browser, it is required to input in advance in a custom scheme which is supported by the Send App and browser. Add LSApplicationQueriesSchemes as below in the Xcode - Project setting - Info - Custom iOS Target Properties or info.plist

![](https://1805733871-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MA9R5J-GVsSkFxuIMzv%2F-MF-PCOlF_3Sdp5YlV7-%2F-MF-TXPJgU6un6DU6mjv%2Fimage.png?alt=media\&token=45aa58cc-71c6-40d4-b6cc-752fbefc3d6d)

info.plist can also add through the editor.

```swift
<key>LSApplicationQueriesSchemes</key>
<array>
<string>customsendscheme </string>
    <string>googlechrome</string>
    <string>googlechromes</string>
    <string>firefox</string>
    <string>naversearchapp</string>
    <string>daumapps</string>
    <string>nate</string>
    <string>opera</string>
    <string>touch-url</string>
    <string>kakaotalk</string>
    <string>access</string>
</array>
```

## 4. Custom Scheme setting

Set Custom Scheme for the environment that does not support the Universal Link. Enter the scheme name as below in the Xcode - Project setting - Info - URL Types or info.plist.

![](https://1805733871-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MA9R5J-GVsSkFxuIMzv%2F-MF-PCOlF_3Sdp5YlV7-%2F-MF-T_6XDWMUsHA-QWgE%2Fimage.png?alt=media\&token=dd733bfc-6cd9-43e3-8ce2-f09bb63280c2)

## 5. API

### 5.1 setFallbackURL

| CLASS     | Content                                                               |
| --------- | --------------------------------------------------------------------- |
| Purpose   | Directs to the market when the target App is not stored in the device |
| Use       | ToAppManager.sharedInstance.setFallbackURL(url: "App Store URL")      |
| Parameter | url *Required*                                                        |
| Return    | void                                                                  |
| Example   | ToAppManager.sharedInstance.setFallbackURL(url: "App Store URL")      |
| Note      | <ul><li>Uses the transmitting App</li></ul>                           |

### 5.2 callApp

| CLASS     | Content                                                                                                                                                                                     |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Purpose   | Use it when calling and forwarding data from the transmitting App to the target App                                                                                                         |
| Use       | <p>ToAppManager.sharedInstance.callApp</p><p>(scheme: "sendappScheme", host: "sendappHost", type: "type", select: "select"</p><p>, responseHost: "myHost", responseScheme: "myScheme")</p>  |
| Parameter | <p>host <em>Required,</em> scheme <em>Required,</em> type <em>Optional,</em> select <em>Optional</em></p><p><em>,</em> responseHost <em>Required,</em> responseScheme <em>Required</em></p> |
| Return    | void                                                                                                                                                                                        |
| Example   | <p>ToAppManager.sharedInstance.callApp</p><p>(scheme: "receivescheme", host: "receivehost", type: "didauth", select: ""</p><p>, responseHost: "sendhost", responseScheme: "sendscheme")</p> |
| Note      | <ul><li>Uses the transmitting App</li></ul>                                                                                                                                                 |

### 5.3 receive

| CLASS     | Content                                                                                                                                   |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| Purpose   | <ul><li>A function that runs on the Appdelegate when the target App runs</li><li>Forwarded data setting on the transmitting App</li></ul> |
| Use       | ToAppManager.sharedInstance.receive(url: URL)                                                                                             |
| Parameter | url *Required*                                                                                                                            |
| Return    | NSMutableDictionary                                                                                                                       |
| Example   | let receiveData = try? ToAppManager.sharedInstance.receive(url: url)                                                                      |
| Note      | <ul><li>Uses the target App</li></ul>                                                                                                     |

### 5.4 returnResult

| CLASS     | Content                                                                                                                                                                   |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Purpuse   | Uses when calling and forwarding data from the target App to transmitting App                                                                                             |
| Use       | try? ToAppManager.sharedInstance.returnResult(result: "base64 encoded string")                                                                                            |
| Parameter | result *Required*                                                                                                                                                         |
| Return    | void                                                                                                                                                                      |
| Example   | <p>let resultText = "callback results for test AppToApp" <br>let encoded = resultText.toBase64()</p><p>try? ToAppManager.sharedInstance.returnResult(result: encoded)</p> |
| Note      | <ul><li>Uses the target App</li></ul>                                                                                                                                     |

### *5.5 resultReceive*

| CLASS     | Content                                                                                                                                                                                                                                                                                                         |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Purpose   | Extracts received data from the target App                                                                                                                                                                                                                                                                      |
| Use       | try? ToAppManager.sharedInstance.resultReceive(resultEnc: "call back data encoded base 64")                                                                                                                                                                                                                     |
| Parameter | resultEnc *Required*                                                                                                                                                                                                                                                                                            |
| Return    | String                                                                                                                                                                                                                                                                                                          |
| Example   | <p>let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) </p><p>let items = urlComponents?.queryItems</p><p>if let result = items?.filter({$0.name == "result"}).first?.value { </p><p>vc.callbackString = try? ToAppManager.sharedInstance.resultReceive(resultEnc: result) </p><p>}</p> |
| Note      | <ul><li>Uses the transmitting App</li></ul>                                                                                                                                                                                                                                                                     |

## 6. Sample Source

### 6.1 Transmitting App

#### 6.1.1 ViewController.swift

```swift
import UIKit
import OmniLink

class ViewController: UIViewController {
 
    override func viewDidLoad() {
        super.viewDidLoad()
        
ToAppManager.sharedInstance.setFallbackURL(url: "App Store URL")
    }
 
    
    @IBAction func callSchemeBtnAction(_ sender: UIButton) {
        ToAppManager.sharedInstance.callApp(scheme: "receivescheme", host: "receivehost", type: "customType", select: "customSelect", responseHost: "sendhost", responseScheme: "sendscheme")
    }
    
}
```

#### 6.1.2 AppDelegate.swift

```swift
import UIKit
import OmniLink

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        return true
    }
    
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)
        let items = urlComponents?.queryItems
        
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
 
        if let result = items?.filter({$0.name == "result"}).first?.value {
            vc.callbackString = try? ToAppManager.sharedInstance.resultReceive(resultEnc: result)
            //… do something with callbackString  
        }

        if let window = self.window {
            let navi = UINavigationController.init(rootViewController: vc)
            window.rootViewController = navi
        }
        
        return true
    }
}
```

### 6.2 Target App

#### 6.2.1 ViewController.swift

```swift
import UIKit
import OmniLink

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad() 
    }

    @IBAction func callbackBtnAction(_ sender: UIButton) {
        
        let resultText = "callback results for test AppToApp"
        let encoded = resultText.toBase64()
        
        // result must be base64 encoded string
        try? ToAppManager.sharedInstance.returnResult(result: encoded)
    }
    
}
```

#### 6.2.2 AppDelegate.swift

```swift
import UIKit
import OmniLink

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }
    
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)
        let items = urlComponents?.queryItems
        
        let receivedDict = try? ToAppManager.sharedInstance.receive(url: url)
        //… do something with receivedDict
        
        return true
    }
}
```
