← 返回目录
📁 Marketing API › Ad Measurement › Guides › TikTok App Events SDK › Additional features

深度链接和延迟深度链接

深度链接

深度链接在原生应用层级进行处理。如果你已按照相关的 Android 和 Apple 开发者指南实现了支持,无需进一步操作。以下代码片段是关于如何在应用中添加相关监听器的示例,仅供参考。

支持的深度链接类型

TikTok 广告管理平台目前支持以下深度链接类型: - Android 应用链接:这些链接的效果与通用链接类似,但专为 Android 设备量身定制。例如:https://yourappdomain.com/path/to/content - Apple 通用链接:这些链接可为 iOS 设备的用户提供无缝体验。例如:https://yourappdomain.com/path/to/content - URI Schema 链接:这些传统的深度链接使用自定义统一资源标识符 (URI) 架构来打开应用。例如:yourappschema://path/to/content

延迟深度链接

借助延迟深度链接,你可以在用户安装并首次启动应用后,将其引导至特定的应用页面。你可以在初始化 SDK 后添加以下代码,以获取并处理延迟深度链接。应在初始化成功的回调中调用此方法,确保其在 SDK 准备就绪后运行。你可能还需要只在首次启动应用时调用一次此方法,以免后续启动时发生意外的重定向。

注意
延迟深度链接仅支持 URI 架构链接。

Android

(code curl http)
// Request a deferred deeplink using this method after successful SDK initialisation
TikTokBusinessSdk.fetchDeferredDeeplinkWithCompletion(new TikTokBusinessSdk.FetchDeferredDeeplinkCompletion() {
    @Override
    public void completion(String deepLinkUrl, ErrorData errorData) {
        if(TextUtils.isEmpty(deepLinkUrl)){
            Log.e("DeferredDeeplink","Failed to fetch deferred deeplink. Code:" + errorData.getCode() + " Msg:"+ errorData.getMsg());
        } else {
            Log.e("DeferredDeeplink","Deferred deeplink fetched:" + deepLinkUrl);
            Uri uri = Uri.parse(deepLinkUrl);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(uri);
            getActivity().startActivity(intent);
        }
    }
});
(/code)

iOS

(code curl http)
// Swift
// Request a deferred deeplink using this method after successful SDK initialisation
TikTokBusiness.fetchDeferredDeeplink { url, error **in**
    **if** error != **nil** {
        print("Failed to fetch deferred deeplink: \(String(describing: error?.localizedDescription))")
    } **else** {
        print("Deferred deeplink fetched: \(url!.absoluteString)")
        **if** url != **nil** && UIApplication.shared.canOpenURL(url!) {
            UIApplication.shared.open(url!, options: [:], completionHandler: **nil**)
        }
    }
}
(/code)
(code curl http)
// Objective-C
// Request a deferred deeplink using this method after successful SDK initialisation
[TikTokBusiness fetchDeferredDeeplinkWithCompletion:^(NSURL * **_Nullable** url, NSError * **_Nullable** error) {
    **if** (error) {
        NSLog(@"Failed to fetch deferred deeplink: %@", error.localizedDescription);
    } **else** {
        NSLog(@"Deferred deeplink fetched: %@", url.absoluteString);
        **if** (url && [[UIApplication sharedApplication] canOpenURL:url]) {
            [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:**nil**];
        }
    }
}];
(/code)

Unity

(code curl http)
// Request a deferred deeplink using this method after successful SDK initialisation
void InitHandle(bool result, int code, string message)
{
    _deeplinkHandle = DeeplinkHandle;
    TikTokBusinessSDK.FetchDeferredDeeplink(_deeplinkHandle);
}

void DeeplinkHandle(string url, int code, string message)
{
    if (code != 0) {
        Debug.Log("Failed to fetch deferred deeplink. Code: " + code + " Msg: " + message);
    } else {
        Debug.Log("Deferred deeplink fetched:"+ url);
    }
}
(/code)

内容来源:TikTok API for Business 官方文档 · 本地归档

在接这个接口时卡住了?
Stuck wiring this API into production? We build ad-delivery tooling on these platforms — campaign automation, reporting pipelines, error-handling and migration between API versions.
联系我们 · Talk to us 每日平台更新简报 →