> For the complete documentation index, see [llms.txt](https://docs.hackle.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackle.io/development-guide/ios/ios-deeplink/ios-deeplink-os.md). Agents can also search and read this documentation through its [MCP server](https://docs.hackle.io/~gitbook/mcp).

# 딥링크 기본 연동

## 기본 동작 <a href="#default-behavior" id="default-behavior"></a>

SDK는 링크 종류에 맞는 iOS 기능으로 링크를 엽니다.

<table><thead><tr><th width="260">링크</th><th>동작</th></tr></thead><tbody><tr><td>딥링크</td><td><code>UIApplication.open</code>으로 엽니다.</td></tr><tr><td>Universal Link</td><td><code>scene(_:continue:)</code> 또는 <code>application(_:continue:restorationHandler:)</code>로 전달합니다.</td></tr><tr><td>그 외 http/https 링크</td><td><code>UIApplication.open</code>으로 엽니다.<br><a href="#universal-link-도메인-확인"><code>universalLinkDomainCheckEnabled</code></a>를 <code>false</code>로 설정하면 Universal Link로 전달합니다.</td></tr></tbody></table>

앱이 활성화되기 전에 받은 Universal Link는 앱이 활성화된 뒤에 전달합니다.

## 링크 수신 설정 <a href="#link-receive-settings" id="link-receive-settings"></a>

앱이 링크를 받으려면 Xcode에서 앱 target에 아래 설정을 추가합니다.

<table><thead><tr><th width="200">링크 종류</th><th>설정</th></tr></thead><tbody><tr><td>딥링크</td><td><strong>Info → URL Types</strong>에 스킴을 등록합니다.</td></tr><tr><td>Universal Link</td><td><strong>Signing &#x26; Capabilities → Associated Domains</strong>에 <code>applinks:example.com</code>을 추가합니다.<br>해당 도메인의 웹 서버에 <code>apple-app-site-association</code> 파일이 있어야 합니다.</td></tr></tbody></table>

{% hint style="info" %}
자세한 설정은 Apple 문서의 [커스텀 URL 스킴 정의](https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app)와 [Associated Domains 지원](https://developer.apple.com/documentation/xcode/supporting-associated-domains)을 참고하세요.
{% endhint %}

## 전달된 링크 처리 <a href="#handle-delivered-link" id="handle-delivered-link"></a>

SDK가 연 링크는 아래 메서드로 앱에 전달됩니다.\
앱 프로젝트 구조에 맞는 메서드에서 링크를 읽어 처리합니다.

### 딥링크 <a href="#deeplink" id="deeplink"></a>

{% tabs %}
{% tab title="SwiftUI" %}

```swift
import SwiftUI

@main
struct sampleApp: App {
  ...
  var body: some Scene {
    WindowGroup {
      ContentView()
        .onOpenURL(perform: { url in
          // Handle opened url
          print("\(url.absoluteString) opened.")
        })
    }
  }
  ...
}
```

{% endtab %}

{% tab title="Storyboard" %}

```swift
class AppDelegate: NSObject, UIApplicationDelegate {
  ...
  func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:] ) -> Bool {
    // Handle opened url
    print("\(url.absoluteString) opened.")
    return true
  }
  ...
}
```

{% endtab %}
{% endtabs %}

### Universal Link

{% tabs %}
{% tab title="SwiftUI" %}

```swift
import SwiftUI

@main
struct sampleApp: App {
  ...
  var body: some Scene {
    WindowGroup {
      ContentView()
        .onContinueUserActivity(NSUserActivityTypeBrowsingWeb) { userActivity in
          guard let url = userActivity.webpageURL else { return }
          // Handle universal link
          print("\(url.absoluteString) opened.")
        }
    }
  }
  ...
}
```

{% endtab %}

{% tab title="SceneDelegate" %}

```swift
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
  ...
  func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
    guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
          let url = userActivity.webpageURL else { return }
    // Handle universal link
    print("\(url.absoluteString) opened.")
  }
  ...
}
```

{% endtab %}

{% tab title="AppDelegate" %}

```swift
class AppDelegate: NSObject, UIApplicationDelegate {
  ...
  func application(
    _ application: UIApplication,
    continue userActivity: NSUserActivity,
    restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
  ) -> Bool {
    guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
          let url = userActivity.webpageURL else { return false }
    // Handle universal link
    print("\(url.absoluteString) opened.")
    return true
  }
  ...
}
```

{% endtab %}
{% endtabs %}

## Universal Link 도메인 확인

{% hint style="info" %}
iOS SDK 4.3.0 버전 이상에서 지원하는 기능입니다.
{% endhint %}

`universalLinkDomainCheckEnabled`로 Associated Domains를 확인할지 설정합니다.\
기본값은 `true`입니다.

* `true`: Associated Domains에 등록된 도메인의 링크만 Universal Link로 전달합니다.
* `false`: 도메인을 확인하지 않고 모든 http/https 링크를 Universal Link로 전달합니다.

딥링크에는 적용되지 않습니다.

{% tabs %}
{% tab title="Swift" %}

```swift
let config = HackleConfigBuilder()
    .universalLinkDomainCheckEnabled(false)
    .build()

Hackle.initialize(sdkKey: YOUR_APP_SDK_KEY, config: config) {
    // SDK ready to use.
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
HackleConfigBuilder *builder = [[HackleConfigBuilder alloc] init];
[builder universalLinkDomainCheckEnabled:NO];
HackleConfig *config = [builder build];

[Hackle initializeWithSdkKey:@"YOUR_APP_SDK_KEY" config:config completion:^{
    // SDK ready to use.
}];
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.hackle.io/development-guide/ios/ios-deeplink/ios-deeplink-os.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
