Set up direct deep linking
You can configure deep linking in your app after you have set it up in the Adjust dashboard. Direct deep linking occurs when a user has your app installed on their device. The link takes the user to a specific page within your app.
To enable deep linking, you need to do the following:
Enable Associated Domains
To get started, you need to enable Associated Domains in your Apple Developer account. This allows you to set universal link domains in your app. To do this, follow these steps:
- Log in to your Apple Developer account.
- Select Certificates, IDs & Profiles in the left-hand menu.
- Select Identifiers in the left-hand menu.
- Find your app and select it to open the edit page.
- Ensure that Associated Domains is checked under Capabilities.
- Select Save to save your changes.
Configure deep links in Xcode
Follow these steps to add your deep link configuration to your Xcode project.
Adjust universal links domain
- Open your app project in Xcode.
- Select your project from the left-hand menu.
- Select your app under Targets.
- Select Signing & Capabilities from the top menu.
- Ensure that All is selected in the submenu below.
- Select the + sign to add a capability.
- Select Associated Domains.
- Enter the Adjust Universal Link domain with the prefix
applinks:
- Here is an example using the
example.adj.st
domain:applinks:example.adj.st
.
- Here is an example using the
Custom URL scheme
- Open your app project in Xcode.
- Select your project from the left-hand menu.
- Select your app under Targets.
- Select Info from the top menu.
- Expand the URL Types section.
- Select the Add option (+) to add a URL type.
- Fill in the following information to create a URL scheme:
- Identifier-
$(PRODUCT_BUNDLE_IDENTIFIER)
- URL Schemes - Your custom URL scheme. This must be unique. Do not use protected schemes such as
http
,https
, ormailto
. - Role-
Editor
- Identifier-
This scheme will work for your production and debug builds.
Modify your iOS app
You need to update your iOS app to set up different deep linking scenarios. How you update your app depends on whether your app uses scenes.
App does not use scenes
If your app does not uses scenes, you need to update methods in your app delegate.
Universal links
Update the application(_:continue:restorationHandler:) method in your app delegate to call the following methods in the Adjust SDK:
ADJLinkResolution.resolveLink
- Call this method only if your marketing team requires the use of Adjust's Link Resolution solution. If the deep link uses a domain that matches an element in theresolveUrlSuffixArray
, then the method attempts to resolve the deep link, and returns the resolved link. If the deep link does not match an element in this array, then the method passes through the original deep link, so you can pass all deep links to this method.Adjust.appWillOpen
- Call this method to send deep links to the Adjust backend for tracking. You can pass both Adjust and non-Adjust deep links to this method. The Adjust backend will ignore any deep links that don’t have Adjust parameters.
When a user clicks on your universal link, iOS opens your app and delivers the deep link to application(_:continue:restorationHandler:)
. This occurs irrespective of whether the user has closed your app, or has it running in the background.
func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void)
-> Bool {
if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
let incomingURL = userActivity.webpageURL
// call the below method to resolve deep link
ADJLinkResolution.resolveLink(
withUrl: incomingURL,
resolveUrlSuffixArray: ["email.example.com", "short.example.com"],
callback: { resolvedURL in
// add your code below to handle deep link
// (e.g., open deep link content)
// resolvedURL object contains the deep link
// call the below method to send deep link to Adjust backend
Adjust.appWillOpen(resolvedURL)
})
} else {
return false
}
return true
}
Custom URL scheme
If your marketing team requires you to set up custom URL scheme deep links, update the application(_:open:options:)
method in your app delegate to call the Adjust.appWillOpen
method in the Adjust SDK. This method sends deep links to the Adjust backend for tracking. You can pass both Adjust and non-Adjust deep links to this method. The Adjust backend will ignore any deep links that don’t have Adjust parameters.
When a user clicks on your custom URL scheme deep link, iOS opens your app and delivers the deep link to application(_:open:options:)
. This occurs irrespective of whether the user has closed your app, or has it running in the background.
func application(
_ app: UIApplication,
open incomingURL: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
// add your code below to handle deep link
// (e.g., open deep link content)
// incomingURL object contains the deep link
// call the below method to send deep link to Adjust backend
Adjust.appWillOpen(incomingURL)
return true
}
App uses scenes
If your app uses scenes, you need to update methods in your scene delegate.
Universal links
- Update the
scene(_:willConnectTo:options:)
method in your scene delegate. When a user clicks on your universal links and the user has your app closed, iOS opens your app and delivers the deep link to this method. - Update the
scene(_:continue:)
method in your scene delegate. When a user clicks on your universal links, and the user has your app running in the background, iOS opens your app and delivers the deep link to this method.
The above methods call the following methods in the Adjust SDK:
ADJLinkResolution.resolveLink
- Call this method only if your marketing team requires the use of Adjust's Link Resolution solution. If the deep link uses a domain that matches an element in theresolveUrlSuffixArray
, then the method attempts to resolve the deep link, and returns the resolved link. If the deep link does not match an element in this array, then the method passes through the original deep link, so you can pass all deep links to this method.Adjust.appWillOpen
- Call this method to send deep links to the Adjust backend for tracking. You can pass both Adjust and non-Adjust deep links to this method. The Adjust backend will ignore any deep links that don’t have Adjust parameters.
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
guard let userActivity = connectionOptions.userActivities.first,
userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingURL = userActivity.webpageURL
else { return }
// call the below method to resolve deep link
ADJLinkResolution.resolveLink(
withUrl: incomingURL,
resolveUrlSuffixArray: ["email.example.com", "short.example.com"],
callback: { resolvedURL in
// add your code below to handle deep link
// (e.g., open deep link content)
// resolvedURL object contains the deep link
// call the below method to send deep link to Adjust backend
Adjust.appWillOpen(resolvedURL)
})
}
func scene(
_ scene: UIScene,
continue userActivity: NSUserActivity) {
if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
let incomingURL = userActivity.webpageURL
// call the below method to resolve deep link
ADJLinkResolution.resolveLink(
withUrl: incomingURL,
resolveUrlSuffixArray: ["email.example.com", "short.example.com"],
callback: { resolvedURL in
// add your code below to handle deep link
// (e.g., open deep link content)
// resolvedURL object contains the deep link
// call the below method to send deep link to Adjust backend
Adjust.appWillOpen(resolvedURL)
})
}
}
Custom URL scheme
- Update the
scene(_:willConnectTo:options:)
method in your scene delegate. When a user clicks on your custom URL scheme deep link and the user has your app closed, iOS opens your app and delivers the deep link to this method. - Update the
scene(_:openURLContexts:)
method in your scene delegate. When a user clicks on your custom URL scheme deep link, and the user has your app running in the background, iOS opens your app and delivers the deep link to this method.
These methods call the Adjust.appWillOpen
method in the Adjust SDK. This method sends deep links to the Adjust backend for tracking. You can pass both Adjust and non-Adjust deep links to this method. The Adjust backend will ignore any deep links that don’t have Adjust parameters.
func scene(
_ scene: UIScene,
openURLContexts URLContexts: Set<UIOpenURLContext>
) {
guard let incomingURL = URLContexts.first?.url else {
return
}
// add your code below to handle deep link
// (e.g., open deep link content)
// incomingURL object contains the deep link
// call the below method to send deep link to Adjust backend
Adjust.appWillOpen(incomingURL)
}