Adjust 的短链接解决方案能将复杂的长链接变成简洁的短链接。短链接会保留深度链接和推广活动信息,如果用户尚未安装您的应用,则会将用户转到应用商店。
使用本节中描述的方法来解析您的短链接。
在 Adjust SDK 中设置深度链接
在 Adjust SDK 中添加对以下内容的支持:
设置 Adjust SDK 来解析短链接
+ (void)processAndResolveDeeplink:(nonnull NSURL *)deeplink withCompletionHandler:(nonnull ADJResolvedDeeplinkBlock)completion;
从 AppDelegate
中调用 processAndResolveDeeplink:completionHandler:
方法来解析将用户深度链接至应用的 Adjust 短 URL 。
- (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. [Adjust processAndResolveDeeplink:[userActivity webpageURL] withCompletionHandler:^(NSString * _Nullable resolvedLink) { // resolvedLink contains either resolved URL (if it was unshortened) // or just echoed URL if it was not shortened }]; } return YES;}
如果您发送至processDeeplink:completionHandler:
方法的链接为短链接,那么resolvedLink
就会返回延长后的原始链接。如果您传递给该方法的链接未被缩短,那么resolvedLink
包含的链接与您传递的链接相同。