Your app can then handle the resolved link by parsing it and navigating to the appropriate screen. You can use this method for all deep links, including Adjust long branded links, other universal links, and app scheme deep links.
The Adjust SDK has the method, appWillOpen(_:), which can record attribution from deep link clicks if you’re not using short branded links.
Method signature
+ (void)appWillOpenUrl:(nonnull NSURL*)url;
However, the processDeeplink(_:completionHandler:) method supersedes the functionality of this legacy method, so it’s recommended to use this newer method.
Important Implementation Notes
Follow these deep link handling best practices:
Link Handling Requirements
Your app should handle Adjust branded links (brandname.go.link) and universal links (example.com) identically. If your app uses a domain allowlist, ensure your Adjust branded domain is included. For example, both of the following should navigate to the same screen:
Your app should handle Adjust branded links and app scheme deep links identically. In cases where iOS doesn’t support universal links, Adjust converts them to the equivalent app scheme format. For example, both of the following should navigate to the same screen:
App scheme deep link: example://summer-clothes?promo=beach
App State Considerations
Ensure your app correctly handles links when they open the app from any state: “not running”, background, or if applicable, foreground.
Consider storing deep links if they can’t be handled immediately, such as when the user isn’t yet authenticated, and process them once the app is ready for navigation.
In-App Navigation
When an app tries to open its own universal links by calling UIApplication.open(_:options:completionHandler:) or SwiftUI’s openURL, iOS opens them in Safari instead of the app. To use these methods for internal navigation, you can only pass app scheme deep links to them. Alternatively, you can place universal links within your app and use your deep link handling logic to parse them and navigate to the appropriate screen.
Implementation
Use the implementation that aligns with your app’s structure:
// Send deep link to Adjust's servers for attribution.
83
// If short branded link, receive long link.
84
// Otherwise, receive original link.
85
[Adjust processDeeplink:incomingLink
86
completionHandler:^(NSString*resolvedLink){
87
// TO DO: Handle resolvedLink by parsing its components
88
// (example: path, query parameters) and
89
// navigating to the appropriate screen.
90
}];
91
}
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, as shown in the example App.swift file below. This is required to handle app lifecycle events and Adjust SDK integration. Also, implement the onOpenURL SwiftUI modifier, which receives universal links and app scheme deep links when the app is installed.
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
7
8
var body: some Scene {
9
WindowGroup {
10
ContentView()
11
// Receive universal link or app scheme deep link when app is installed
12
// and link opens app from "not running",
13
// background, or foreground state.
14
.onOpenURL { incomingLink in
15
// Send deep link to Adjust's servers for attribution.
16
// If short branded link, receive long link.
17
// Otherwise, receive original link.
18
Adjust.processDeeplink(incomingLink) { resolvedLink in
19
// TO DO: Handle resolvedLink by parsing its components
20
// (example: path, query parameters) and
21
// navigating to the appropriate screen.
22
}
23
}
24
}
25
}
26
}
SwiftUI apps using SceneDelegate lifecycle
Follow the instructions in the SwiftUI apps using AppDelegate lifecycle section. The onOpenURL SwiftUI modifier receives universal links and app scheme deep links when the app is installed and the link opens the app from a background or foreground state.
In addition, implement the scene(_:willConnectTo:options:) method from the UIKit apps using SceneDelegate lifecycle section. This method receives universal links and app scheme deep links when the app is installed and the link opens the app from a “not running” state.