adjust-icon

Set up deep linking

Please follow the steps in the section that corresponds to the type of app you have:

In addition, implement deep link handling logic:

UIKit apps using AppDelegate lifecycle

Update your AppDelegate to implement direct and deferred deep linking.

Most apps have some kind of onboarding process (for example: ATT prompt, onboarding screens, login prompt). When setting up deferred deep linking, you have to ensure that onboarding and launching deferred deep links don’t interfere with each other. One approach is to wait until after onboarding to launch deferred deep links. Here’s how it works in the code examples:

  1. A user who doesn’t have the app installed clicks an Adjust deep link, which redirects them to the app store.
  2. The user installs and opens the app.
  3. The app begins its onboarding process.
  4. After the ATT prompt response or timeout, the Adjust SDK sends session and attribution requests to Adjust’s servers.
  5. Adjust’s servers respond with attribution data, including the deep link the user clicked on (“deferred deep link”).
  6. The Adjust SDK triggers a deferred deep link callback in the app (shown in the AppDelegate implementation above). The callback checks whether onboarding is complete:
    • If onboarding is complete, it handles the deep link immediately.
    • If onboarding isn’t complete, it stores the deep link.
  7. Once onboarding completes, the app checks for and handles any stored deferred deep link (shown in the ViewController example class below).
  8. The app navigates the user to the deep link screen.

Lastly, implement your deep link handling logic:

Deep link handler

UIKit apps using SceneDelegate lifecycle

Follow the steps in the UIKit apps using AppDelegate lifecycle section, except instead of implementing the application(_:continue:restorationHandler:) and application(_:open:options:) methods in your AppDelegate for direct deep linking, implement the following methods in your SceneDelegate.

SwiftUI apps using AppDelegate lifecycle

If you haven’t already done so, create an AppDelegate.swift file in your project’s main directory and reference it in your main application file (for example: App.swift as shown below). This is required to handle app lifecycle events and Adjust SDK integration. Also implement onOpenURL, which receives all direct deep links.

Update your AppDelegate to implement deferred deep linking.

Most apps have some kind of onboarding process (for example: ATT prompt, onboarding screens, login prompt). When setting up deferred deep linking, you have to ensure that onboarding and launching deferred deep links don’t interfere with each other. One approach is to wait until after onboarding to launch deferred deep links. Here’s how it works in the code examples:

  1. A user who doesn’t have the app installed clicks an Adjust deep link, which redirects them to the app store.
  2. The user installs and opens the app.
  3. The app begins its onboarding process.
  4. After the ATT prompt response or timeout, the Adjust SDK sends session and attribution requests to Adjust’s servers.
  5. Adjust’s servers respond with attribution data, including the deep link the user clicked on (“deferred deep link”).
  6. The Adjust SDK triggers a deferred deep link callback in the app (shown in the AppDelegate implementation above). The callback checks whether onboarding is complete:
    • If onboarding is complete, it handles the deep link immediately.
    • If onboarding isn’t complete, it stores the deep link.
  7. Once onboarding completes, the app checks for and handles any stored deferred deep link (shown in the ContentView example class below).
  8. The app navigates the user to the deep link screen.

Lastly, implement your deep link handling logic:

Deep link handler

SwiftUI apps using SceneDelegate lifecycle

Follow the steps in the SwiftUI apps using AppDelegate lifecycle. In addition, implement the following method in your SceneDelegate.

The preceding code examples use an example DeeplinkHandler class. This example class is shown below and handles all types of links:

  • Adjust branded links (full go.link links)
  • Adjust short branded links (short go.link links)
  • Adjust universal links (adj.st links)
  • Non-Adjust universal links (example.com links)
  • App scheme deep links (example:// links)

The class performs the following tasks:

  1. The class uses Adjust’s processAndResolveDeeplink method, which sends the deep link to Adjust’s servers to accomplish two things:
  • Record the deep link click for attribution purposes.
  • If the deep link is an Adjust short branded link, respond with the corresponding full URL. Otherwise, respond with the original link.
  1. After processing, the class parses the link and navigates to the appropriate screen. This part of the code is specific to each app. Your app has to implement its own logic for handling deep links and opening the corresponding content. Your deep link handling has to meet the following key requirements:
  • Your app should treat Adjust branded links the same as other universal links, such as your own. For example, the following links should navigate to the same screen in your app:
    • Adjust branded link: https://example.go.link/summer-clothes?promo=beach
    • Your universal link: https://www.example.com/summer-clothes?promo=beach
  • In cases where iOS doesn’t support universal links, Adjust automatically converts them to app scheme deep links. Additionally, Adjust’s servers convert all deferred deep links to app scheme deep link format. Therefore it’s crucial for the app to handle universal links and app scheme deep links equivalently. For example, the following links should navigate to the same screen in your app:
    • Adjust branded link: https://example.go.link/summer-clothes?promo=beach
    • App scheme deep link: example://summer-clothes?promo=beach