Adjust 的短链接解决方案能将复杂的长链接变成简洁的短链接。短链接会保留深度链接和推广活动信息,如果用户尚未安装您的应用,则会将用户转到应用商店。
使用本节中描述的方法来解析您的短链接。
在 Adjust SDK 中设置深度链接
在 Adjust SDK 中添加对以下内容的支持:
设置 Adjust SDK 来解析短链接
+ (void)processAndResolveDeeplink:(nonnull NSURL *)deeplink
withCompletionHandler:(nonnull ADJResolvedDeeplinkBlock)completion;
从 AppDelegate
中调用 processAndResolveDeeplink:completionHandler:
方法来解析将用户深度链接至应用的 Adjust 短 URL 。
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([any UIUserActivityRestoring]?) -> Void) -> Bool {
if userActivity.activityType.isEqual(NSUserActivityTypeBrowsingWeb) {
// Pass deep link URL to Adjust in order to potentially reattribute the user
// and to get the URL resolved if it’s a shortened one.
if let incomingURL = userActivity.webpageURL {
if let deeplink = ADJDeeplink(deeplink: incomingURL) {
Adjust.processAndResolve(deeplink) { resolveDeeplink in
// resolvedLink contains either resolved URL (if it was unshortened)
// or just echoed URL if it was not shortened
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<uiuseractivityrestoring>> *restorableObjects))restorationHandler {
if ([[userActivity activityType] isEqualToString:NSUserActivityTypeBrowsingWeb]) {
// Pass deep link URL to Adjust in order to potentially reattribute the user
// and to get the URL resolved if it’s a shortened one.
ADJDeeplink *deeplink = [[ADJDeeplink alloc] initWithDeeplink:[userActivity webpageURL]];
[Adjust processAndResolveDeeplink:deeplink
withCompletionHandler:^(NSString * _Nullable resolvedLink) {
// resolvedLink contains either resolved URL (if it was unshortened)
// or just echoed URL if it was not shortened
如果您发送至processDeeplink:completionHandler:
方法的链接为短链接,那么resolvedLink
就会返回延长后的原始链接。如果您传递给该方法的链接未被缩短,那么resolvedLink
包含的链接与您传递的链接相同。
处理带有 referrer 的深度链接
可选 referrer URL,用于跟踪深度链接或应用打开的来源,以优化归因或再归因和深度链接。例如,对于 SEO / 自然搜索等渠道,Adjust 链接不会直接被使用。如果客户的根域已部署通用链接,并触发了应用打开,那么对于此类渠道来说,我们可能必须通过 referrer URL 传入的信号开展用户归因或再归因。
设置 referrer URL
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if userActivity.activityType.isEqual(NSUserActivityTypeBrowsingWeb) {
// Pass deep link URL to Adjust in order to potentially reattribute the user
// and to get the URL resolved if it’s a shortened one.
if let incomingURL = userActivity.webpageURL {
if let deeplink = ADJDeeplink(deeplink: incomingURL) {
// If referrer URL is available, add it to the deeplink object
if let referrer = URL(string: "https://example.com") {
deeplink.setReferrer(referrer)
Adjust.processAndResolve(deeplink) { resolveDeeplink in
// resolvedLink contains either resolved URL (if it was unshortened)
// or just echoed URL if it was not shortened
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<uiuseractivityrestoring>> *restorableObjects))restorationHandler {
if ([[userActivity activityType] isEqualToString:NSUserActivityTypeBrowsingWeb]) {
// Pass deep link URL to Adjust in order to potentially reattribute the user
// and to get the URL resolved if it’s a shortened one.
ADJDeeplink *deeplink = [[ADJDeeplink alloc] initWithDeeplink:[userActivity webpageURL]];
NSURL *referrer = [NSURL URLWithString:@"https://example.com"];
// If referrer URL is available, add it to the deeplink object
[deeplink setReferrer:referrer];
[Adjust processAndResolveDeeplink:deeplink
withCompletionHandler:^(NSString * _Nullable resolvedLink) {
// resolvedLink contains either resolved URL (if it was unshortened)
// or just echoed URL if it was not shortened