title | description | slug | sidebar-position | versions | redirects | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Set up direct deep linking |
Configure direct deep linking for your app. |
en/sdk/ios/v4/features/deep-links/direct |
3 |
|
|
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:
- [ ] Set up the same branded domain for your iOS and Android app in AppView in Adjust.
- [ ] Enable Associated Domains for your app
- [ ] Configure your deep links in Xcode
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.
Follow these steps to add your deep link configuration to your Xcode project.
- 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 Add option (+) 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
- Enter the branded link domain that you set up while setting up the branded domain for your app in Adjust.
- Here is an example using the
brandedDomain.go.link
domain:brandedDomain.go.link
.
- Here is an example using the
If you are already using xxx.adj.st
as your universal link domain, do not remove it. Keep both xxx.adj.st
and brandedDomain.go.link
as the associated domains.
Check with your marketing team to see if a custom URL scheme is needed for the app and discuss what the scheme name should be. If your app targets Android devices as well, use the same scheme name for each platform.
- 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. Don't use protected schemes such as
http
,https
, ormailto
. - Role: Editor
- Identifier:
This scheme will work for your production and debug builds.
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.
If your app doesn't uses scenes, you need to update methods in your app delegate.
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 doesn't 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 Adjust's servers to record information. You can pass both Adjust and non-Adjust deep links to this method. Adjust's servers 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 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
// (for example, open deep link content)
// resolvedURL object contains the deep link
// call the below method to send deep link to Adjust's servers
Adjust.appWillOpen(resolvedURL)
})
} else {
return false
}
return true
}
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:
(void (^)(NSArray *restorableObjects))restorationHandler {
if ([[userActivity activityType]
isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSURL *incomingURL = [userActivity webpageURL];
// call the below method to resolve deep link
[ADJLinkResolution
resolveLinkWithUrl:incomingURL
resolveUrlSuffixArray:@[
@"email.example.com", @"short.example.com"
]
callback:^(NSURL* _Nullable resolvedURL) {
// add your code below to handle deep link
// (for example, open deep link content)
// resolvedURL object contains the deep link
// call the below method to send deep link to Adjust's servers
[Adjust appWillOpenUrl:resolvedURL];
}];
} else {
return NO;
}
return YES;
}
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 Adjust's servers to record them. You can pass both Adjust and non-Adjust deep links to this method. Adjust's servers 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 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
// (for example, open deep link content)
// incomingURL object contains the deep link
// call the below method to send deep link to Adjust's servers
Adjust.appWillOpen(incomingURL)
return true
}
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)incomingURL
options:(NSDictionary *)options {
// add your code below to handle deep link
// (for example, open deep link content)
// incomingURL object contains the deep link
// call the below method to send deep link to Adjust's servers
[Adjust appWillOpenUrl:incomingURL];
return YES;
}
If your app uses scenes, you need to update methods in your scene delegate.
- 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 doesn't 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 Adjust's servers to record them. You can pass both Adjust and non-Adjust deep links to this method. Adjust's servers 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
// (for example, open deep link content)
// resolvedURL object contains the deep link
// call the below method to send deep link to Adjust's servers
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
// (for example, open deep link content)
// resolvedURL object contains the deep link
// call the below method to send deep link to Adjust's servers
Adjust.appWillOpen(resolvedURL)
})
}
}
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session
options:(UISceneConnectionOptions *)connectionOptions {
NSUserActivity* userActivity =
[[[connectionOptions userActivities] allObjects] firstObject];
if ([[userActivity activityType]
isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSURL *incomingURL = [userActivity webpageURL];
// call the below method to resolve deep link
[ADJLinkResolution
resolveLinkWithUrl:incomingURL
resolveUrlSuffixArray:@[
@"email.example.com", @"short.example.com"
]
callback:^(NSURL* _Nullable resolvedURL) {
// add your code below to handle deep link
// (for example, open deep link content)
// resolvedURL object contains the deep link
// call the below method to send deep link to Adjust's servers
[Adjust appWillOpenUrl:resolvedURL];
}];
}
}
- (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity{
if ([[userActivity activityType]
isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSURL *incomingURL = [userActivity webpageURL];
// call the below method to resolve deep link
[ADJLinkResolution
resolveLinkWithUrl:incomingURL
resolveUrlSuffixArray:@[
@"email.example.com", @"short.example.com"
]
callback:^(NSURL* _Nullable resolvedURL) {
// add your code below to handle deep link
// (for example, open deep link content)
// resolvedURL object contains the deep link
// call the below method to send deep link to Adjust's servers
[Adjust appWillOpenUrl:resolvedURL];
}];
}
}
- 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 Adjust's servers to recordd them. You can pass both Adjust and non-Adjust deep links to this method. Adjust's servers 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
// (for example, open deep link content)
// incomingURL object contains the deep link
// call the below method to send deep link to Adjust's servers
Adjust.appWillOpen(incomingURL)
}
- (void)scene:(UIScene *)scene
openURLContexts:(nonnull NSSet<UIOpenURLContext *> *)URLContexts {
NSURL *incomingURL = [[URLContexts allObjects] firstObject].URL;
if (incomingURL) {
// add your code below to handle deep link
// (for example, open deep link content)
// incomingURL object contains the deep link
// call the below method to send deep link to Adjust's servers
[Adjust appWillOpenUrl:incomingURL];
}
}