> 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/en/development-guide/ios/ios-deeplink/ios-deeplink-os.md).

# Basic Deep Link Integration

## Default Behavior

The SDK opens links using the iOS feature that matches the link type.

<table><thead><tr><th width="260">Link</th><th>Behavior</th></tr></thead><tbody><tr><td>Deep Link</td><td>Opened with <code>UIApplication.open</code>.</td></tr><tr><td>Universal Link</td><td>Delivered to <code>scene(_:continue:)</code> or <code>application(_:continue:restorationHandler:)</code>.</td></tr><tr><td>Other http/https links</td><td>Opened with <code>UIApplication.open</code>.<br>If you set <a href="#universal-link-domain-check"><code>universalLinkDomainCheckEnabled</code></a> to <code>false</code>, they are delivered as Universal Links.</td></tr></tbody></table>

Universal Links received before the app becomes active are delivered after the app becomes active.

## Link Receive Settings

For the app to receive links, add the following settings to the app target in Xcode.

<table><thead><tr><th width="200">Link Type</th><th>Setting</th></tr></thead><tbody><tr><td>Deep Link</td><td>Register a scheme in <strong>Info → URL Types</strong>.</td></tr><tr><td>Universal Link</td><td>Add <code>applinks:example.com</code> to <strong>Signing &#x26; Capabilities → Associated Domains</strong>.<br>The web server for that domain must host an <code>apple-app-site-association</code> file.</td></tr></tbody></table>

{% hint style="info" %}
For detailed setup, see Apple's documentation on [Defining a custom URL scheme for your app](https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app) and [Supporting associated domains](https://developer.apple.com/documentation/xcode/supporting-associated-domains).
{% endhint %}

## Handle Delivered Link

Links opened by the SDK are delivered to the app through the methods below.\
Read and handle the link in the method that matches your app project structure.

### Deep Link

{% 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 Domain Check

{% hint style="info" %}
This feature is supported in iOS SDK 4.3.0 and above.
{% endhint %}

Use `universalLinkDomainCheckEnabled` to set whether to check Associated Domains.\
The default value is `true`.

* `true`: Only links from domains registered in Associated Domains are delivered as Universal Links.
* `false`: All http/https links are delivered as Universal Links without checking the domain.

This setting does not apply to deep links.

{% 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/en/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.
