整合安全信號轉接器
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
安全信號是從用戶端裝置收集並與特定出價方共用的編碼資料。本指南說明如何使用 IMA SDK 收集安全信號並傳送至 Google Ad Manager。
安全信號 API 須使用 IMA SDK for tvOS 4.8.2 以上版本。
如要選取信號和出價方,並啟用安全信號共用功能,請參閱「與出價方共用安全信號」。
使用第三方信號供應商
如要使用安全信號,您必須在應用程式中部署信號收集器轉接器類別,收集信號、編碼並傳遞至 IMA SDK。
請按照第三方供應商的操作說明,向他們設定帳戶、加入架構,並在應用程式中設定安全信號轉接程式。
tvOS 適用的 IMA SDK 會自動初始化每個安全信號轉接程式,不需要對程式碼進行任何額外變更。
以下範例說明如何在專案中加入安全信號轉接程式:

傳送自訂資料
除了使用第三方信號供應商,您也可以收集、編碼及傳送含有自訂資料的信號。如要傳送含有自訂資料的安全信號,請務必先在 Ad Manager 中啟用自訂信號。
針對每項廣告請求,建立 IMASecureSignals
物件,其中包含編碼的自訂資料 (以字串形式)。接著,請呼叫 IMAAdsRequest.secureSignals
屬性,將 IMASecureSignals
物件加入廣告請求。
以下是 Objective-C 和 Swift 的範例:
Objective-C
BasicExample/ViewController.m
...
- (void)requestAds {
// Create an ad display container for ad rendering.
IMAAdDisplayContainer *adDisplayContainer =
[[IMAAdDisplayContainer alloc] initWithAdContainer:self.videoView
viewController:self
companionSlots:nil];
// Create an ad request with our ad tag, display container, and optional user context.
IMAAdsRequest *request = [[IMAAdsRequest alloc] initWithAdTagUrl:kTestAppAdTagUrl
adDisplayContainer:adDisplayContainer
contentPlayhead:self.contentPlayhead
userContext:nil];
IMASecureSignals *signals =
[[IMASecureSignals alloc] initWithCustomData:@"My encoded signal string"];
request.secureSignals = signals;
[self.adsLoader requestAdsWithRequest:request];
}
...
Swift
BasicExample/ViewController.swift
...
private func requestAds() {
// Create ad display container for ad rendering.
let adDisplayContainer = IMAAdDisplayContainer(
adContainer: videoView, viewController: self, companionSlots: nil)
// Create an ad request with our ad tag, display container, and optional user context.
let request = IMAAdsRequest(
adTagUrl: ViewController.testAppAdTagURL,
adDisplayContainer: adDisplayContainer,
contentPlayhead: contentPlayhead,
userContext: nil)
let signals = IMASecureSignals(customData: "My encoded signal string")
request.secureSignals = signals
adsLoader.requestAds(with: request)
}
...
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eSecure signals, encoded data from client devices, are shared with specific bidders to enhance ad targeting.\u003c/p\u003e\n"],["\u003cp\u003eYou need to integrate a signal collector adapter and the IMA SDK (version 4.8.2 or higher for tvOS) to collect and send secure signals to Google Ad Manager.\u003c/p\u003e\n"],["\u003cp\u003eUtilize a third-party signal provider or, if eligible for a limited beta, send custom data as secure signals after enabling it in Ad Manager.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the provided code examples (Objective-C and Swift) for implementation guidance on adding secure signals to your ad requests.\u003c/p\u003e\n"]]],[],null,["Secure signals are encoded data that is collected on the client device and\nshared with select bidders. This guide shows you how to collect and send secure\nsignals to Google Ad Manager using the IMA SDK.\n\nThe secure signals API requires version 4.8.2\nor higher of the IMA SDK for tvOS.\n\nTo select signals and bidders, and enable secure signal sharing, see [Share\nsecure signals with bidders](//support.google.com/admanager/answer/10488752).\n\nUse a third-party signal provider\n\nTo use secure signals, you must deploy a signal collector\n\nadapter class in your app\n\nto collect signals, encode them, and pass them to the IMA SDK.\n\n\u003cbr /\u003e\n\nFollow your third-party provider's instructions to set up an account with them,\n\n[include frameworks](//developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/IncludingFrameworks.html),\n\nand set up their secure signals adapter in your app.\n\nThe IMA SDK for tvOS automatically\ninitializes each secure signals adapter, without any additional changes to your\ncode.\n\nHere's an example of how you might add a secure signals adapter to your project:\n\n\u003cbr /\u003e\n\nSend custom data\n\nIn addition to using a third-party signal provider, you can also collect,\nencode, and send signals with custom data. Before you can send secure signals\nwith custom data, you must turn on custom signals in Ad Manager.\n\n\u003cbr /\u003e\n\nFor each ad request, create an `IMASecureSignals` object containing your\nencoded custom data as a string. Then, add the `IMASecureSignals` object to\nyour ad request by calling the `IMAAdsRequest.secureSignals` attribute.\n\nHere are samples in Objective-C and Swift: \n\nObjective-C\n\n**BasicExample/ViewController.m** \n\n ...\n - (void)requestAds {\n // Create an ad display container for ad rendering.\n IMAAdDisplayContainer *adDisplayContainer =\n [[IMAAdDisplayContainer alloc] initWithAdContainer:self.videoView\n viewController:self\n companionSlots:nil];\n // Create an ad request with our ad tag, display container, and optional user context.\n IMAAdsRequest *request = [[IMAAdsRequest alloc] initWithAdTagUrl:kTestAppAdTagUrl\n adDisplayContainer:adDisplayContainer\n contentPlayhead:self.contentPlayhead\n userContext:nil];\n IMASecureSignals \\*signals =\n \\[\\[IMASecureSignals alloc\\] initWithCustomData:@\"My encoded signal string\"\\];\n request.secureSignals = signals;\n [self.adsLoader requestAdsWithRequest:request];\n }\n ...\n\nSwift\n\n**BasicExample/ViewController.swift** \n\n ...\n private func requestAds() {\n // Create ad display container for ad rendering.\n let adDisplayContainer = IMAAdDisplayContainer(\n adContainer: videoView, viewController: self, companionSlots: nil)\n // Create an ad request with our ad tag, display container, and optional user context.\n let request = IMAAdsRequest(\n adTagUrl: ViewController.testAppAdTagURL,\n adDisplayContainer: adDisplayContainer,\n contentPlayhead: contentPlayhead,\n userContext: nil)\n let signals = IMASecureSignals(customData: \"My encoded signal string\")\n request.secureSignals = signals\n adsLoader.requestAds(with: request)\n }\n ..."]]