您可以直接取代.xml檔案,以在TVML/TVJS應用程式中運用Adobe Target。 使用自訂ADBTarget XML元素,指定要由Target內容取代的頁面區域。
您必須將 TVML/TVJS 應用程式設定為使用 tvOS SDK,才能在 TVML 頁面中使用 ADBTarget
元素。如需詳細資訊,請參閱使用 tvOS 實施 Apple TV。
.xml
檔案。ADBTarget
元素新增至檔案,做為 <document>
元素的子項。<ADBTarget>
標籤和 </ADBTarget>
標籤之間的值做為預設內容。從 Target 傳回的內容會替換 <ADBTarget>
和 </ADBTarget>
之間的所有內容 (包括這兩個 ADBTarget
標籤)。
您對於要替換的內容應有相應的規劃。
您的使用案例可能會簡單如替換某標籤中的字串值,或複雜到替換整個頁面。
在 ADBTarget
元素中,您必須在 mbox
屬性中提供 mbox 名稱。您可以選擇將自訂屬性以 customParameterName="customParameterValue"
格式新增至您的要求。
mbox
mbox 位置的名稱.
id
訂購 ID。
total
訂購總計。
purchasedProductIds
此訂購中的購買產品 ID 清單 (以逗號分隔)。
以下是此屬性的範例程式碼:
purchasedProductIds="product1,product2,product3"
屬性類型: 字串
此屬性並非必要。
mboxParameters
mboxParameters
的鍵值值組清單。此字串中的每筆輸入之間以分號分隔,而索引鍵/值則是以冒號分隔。
以下是此屬性的範例程式碼:
mboxParameters="mboxparameterKey:mboxParameterValue;mboxParameterKey1:mboxParameterValue1;mboxParameterKey2:mboxParameterValue2"
屬性類型: 字串
此屬性並非必要。
customParameterName
此屬性的值為 customParameterValue
。
下列範例是使用 ADBTarget
頁面中的 LandingPage.xml.js
元素來替換提醒內容:
假設您有一個命名為 landingPage
的 mbox 位置,則選件內容的設定如下:
<title>My cool landing page</title>
<description>Thanks for coming to my page</description>
以下是landingPage.xml.js的設定:
<alertTemplate>
<ADBTarget mbox="landingPage">
<title>TargetTestPage</title>
<description>Load fail or timeout (defaultContent)</description>
</ADBTarget>
</alertTemplate>
如果向Target提出的請求成功,並傳回您的選件內容,則您的頁面會產生:
<alertTemplate>
<title>My cool landing page</title>
<description>Thanks for coming to my page</description>
</alertTemplate>
如果無法連線Target伺服器或請求逾時,您的頁面會產生下列結果:
<alertTemplate>
<title>TargetTestPage</title>
<description>Load fail or timeout (defaultContent)</description>
</alertTemplate>
下列範例說明如何將自訂資料新增至您的 ADBTarget
元素。此方法可讓您為 Target 中的此 mbox 位置建立條件式體驗和選件內容。
<alertTemplate>
<ADBTarget mbox="landingPage" customData="custom data" moreCustomData="more custom data">
<title>TargetTestPage</title>
<description>Load fail or timeout (defaultContent)</description>
</ADBTarget>
</alertTemplate>