進階功能提供自訂區段;自訂視圖允許您顯示所需的 HTML 頁面,自訂看板可以顯示自訂公告欄,Spot Banner 和 Direct View 可以在所需位置顯示在 Hive 控制台上註冊的特定橫幅。
自訂視圖¶
自訂視圖是一個功能,能夠將外部 URL 或輸入內容顯示在遊戲中的網頁視圖中,並配有一個獨立的按鈕。在遊戲中可以使用一個或多個自訂視圖,因此可以在不同情況下以多種方式使用。
註冊¶
Hive 控制台提供了一個編輯器來創建和組合自定義視圖。您可以通過 Hive 控制台註冊外部鏈接,與設置一般自定義視圖的方式相同。 有關創建和註冊自定義視圖的更多信息,請參見 Hive 控制台促銷。
創建¶
要在 Hive 控制台或外部页面上显示注册的自定义视图,请调用Promotion 类的 showCustomContents()
方法,如以下说明所示。
- 將 customType 設定為
PromotionCustomType.VIEW
參數。 - 將 contentsKey 參數設定為 自訂視圖 ID 在 Hive 控制台 > 促銷 > 活動設定 > 自訂視圖標籤 > 管理名稱。
API 參考: hive.Promotion.showCustomContents
using hive;
PromotionCustomType customType = PromotionCustomType.VIEW;
String contentsKey = "12345";
Promotion.showCustomContents(customType, contentsKey, (ResultAPI result, PromotionEventType viewEventType) => {
if (!result.isSuccess()) {
return;
}
// call successful
switch (viewEventType) {
case OPEN:
// Open promotion view
break;
case CLOSE:
// Close promotion view
break;
}
});
#include "HivePromotion.h"
EHivePromotionCustomType PromotionCustomType = EHivePromotionCustomType::VIEW;
FString ContentsKey = TEXT("12345");
FHivePromotion::ShowCustomContents(PromotionCustomType, ContentsKey, FHivePromotionViewDelegate::CreateLambda([this](const FHiveResultAPI& Result, const EHivePromotionEventType& PromotionEventType) {
if (!Result.IsSuccess()) {
return;
}
// API 呼叫成功
switch (PromotionEventType) {
case EHivePromotionEventType::OPEN:
// 促銷視圖開啟
break;
case EHivePromotionEventType::CLOSE:
// 促銷視圖關閉
break;
default:
// 其他事件發生
break;
}
}));
API 參考: Promotion::showCustomContents
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
PromotionCustomType customType = PromotionCustomType::VIEW;
string contentsKey = "12345";
Promotion::showCustomContents(customType, contentsKey, [=](ResultAPI result, PromotionEventType viewEventType) {
if (!result.isSuccess()) {
return;
}
// call successful
switch (viewEventType) {
case OPEN:
// Open promotion view
break;
case CLOSE:
// Close promotion view
break;
}
});
API 參考: Promotion.showCustomContents
import com.hive.Promotion
import com.hive.ResultAPI
val promotionCustomType = Promotion.PromotionCustomType.VIEW
val contentsKey = "12345"
Promotion.showCustomContents(promotionCustomType, contentsKey, object : Promotion.PromotionViewListener {
override fun onPromotionView(result: ResultAPI, promotionEventType: Promotion.PromotionViewResultType) {
if (!result.isSuccess) {
return
}
// call successful
when (promotionEventType) {
Promotion.PromotionViewResultType.OPENED -> {
// Open promotion view
}
Promotion.PromotionViewResultType.CLOSED -> {
// Close promotion view
}
}
}
})
API 參考: Promotion.INSTANCE.showCustomContents
import com.hive.Promotion;
import com.hive.ResultAPI;
Promotion.PromotionCustomType promotionCustomType = Promotion.PromotionCustomType.VIEW;
String contentsKey = "12345";
Promotion.INSTANCE.showCustomContents(promotionCustomType, contentsKey, (result, viewResultType) -> {
if (!result.isSuccess()) {
return;
}
// call successful
switch (viewResultType) {
case OPENED:
// Open promotion view
break;
case CLOSED:
// Close promotion view
break;
}
});
API 參考: PromotionInterface.showCustomContents
import HIVEService
let type = PromotionCustomType.view
let contentsKey = "12345"
PromotionInterface.showCustomContents(type, contents: contentsKey) { result, viewResultType in
if !result.isSuccess() {
return
}
// call successful
switch viewResultType {
case .open:
// Open promotion view
case .close:
// Close promotion view
}
}
API 參考: HivePromotion:showCustomContents
#import <HIVEService/HIVEService-Swift.h>
HIVEPromotionCustomType type = HIVEPromotionCustomTypeVIEW;
NSString *contentsKey = @"12345";
[HIVEPromotion showCustomContents: type contents: contentsKey handler: ^(HIVEResultAPI *result, HIVEPromotionViewResultType viewResultType) {
if (![result isSuccess]) {
return;
}
// call successful
switch (viewResultType) {
case HIVEPromotionViewResultTypeOpen:
// Open promotion view
break;
case HIVEPromotionViewResultTypeClose:
// Close promotion view
break;
}
}];
自訂面板¶
與一般的促銷通知不同,自訂公告板可以顯示遊戲內各種用途的公告板列表。
註冊¶
有關創建和註冊自定義板的更多信息,請參見Hive 控制台促銷指南。
創建¶
要顯示自訂面板,請按照以下說明設置參數,然後調用Promotion類的showCustomContents()
方法。
- 將 customType 設為
PromotionCustomType.BOARD
參數。 - 在 Hive 控制台 > 推廣 > 自訂看板 中將 contentsKey 參數設為 看板鍵。
以下是顯示自定義面板的示例代碼。
API 參考: hive.Promotion.showCustomContents
using hive;
PromotionCustomType customType = PromotionCustomType.BOARD;
String contentsKey = "12345";
Promotion.showCustomContents(customType, contentsKey, (ResultAPI result, PromotionEventType viewEventType) => {
if (!result.isSuccess()) {
return;
}
// call successful
switch (viewEventType) {
case OPEN:
// Open promotion view
break;
case CLOSE:
// Close promotion view
break;
}
});
#include "HivePromotion.h"
EHivePromotionCustomType PromotionCustomType = EHivePromotionCustomType::BOARD;
FString ContentsKey = TEXT("12345");
FHivePromotion::ShowCustomContents(PromotionCustomType, ContentsKey, FHivePromotionViewDelegate::CreateLambda([this](const FHiveResultAPI& Result, const EHivePromotionEventType& PromotionEventType) {
if (!Result.IsSuccess()) {
return;
}
// API 呼叫成功
switch (PromotionEventType) {
case EHivePromotionEventType::OPEN:
// 開啟促銷視圖
break;
case EHivePromotionEventType::CLOSE:
// 關閉促銷視圖
break;
default:
// 其他事件發生
break;
}
}));
API 參考: Promotion::showCustomContents
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
PromotionCustomType customType = PromotionCustomType::BOARD;
string contentsKey = "12345";
Promotion::showCustomContents(customType, contentsKey, [=](ResultAPI result, PromotionEventType viewEventType) {
if (!result.isSuccess()) {
return;
}
// call successfull
switch (viewEventType) {
case OPEN:
// Open promotion view
break;
case CLOSE:
// Close promotion view
break;
}
});
API 參考: Promotion.showCustomContents
import com.hive.Promotion
import com.hive.ResultAPI
val promotionCustomType = Promotion.PromotionCustomType.BOARD
val contentsKey = "12345"
Promotion.showCustomContents(promotionCustomType, contentsKey, object : Promotion.PromotionViewListener {
override fun onPromotionView(result: ResultAPI, promotionEventType: Promotion.PromotionViewResultType) {
if (!result.isSuccess) {
return
}
// call successful
when (promotionEventType) {
Promotion.PromotionViewResultType.OPENED -> {
// Open promotion view
}
Promotion.PromotionViewResultType.CLOSED -> {
// Close promotion view
}
}
}
})
API 參考: com.hive.Promotion.showCustomContents
import com.hive.Promotion;
import com.hive.ResultAPI;
Promotion.PromotionCustomType promotionCustomType = Promotion.PromotionCustomType.BOARD;
String content_key = "12345";
Promotion.INSTANCE.showCustomContents(promotionCustomType, content_key, (result, viewResultType) -> {
if (!result.isSuccess()) {
return;
}
// call successful
switch (viewResultType) {
case OPENED:
// Open promotion view
break;
case CLOSED:
// Close promotion view
break;
}
});
API 參考: PromotionInterface.showCustomContents
import HIVEService
let type = PromotionCustomType.board
let contentsKey = "12345"
PromotionInterface.showCustomContents(type, contents: contentsKey) { result, viewResultType in
if !result.isSuccess() {
return
}
// call successful
switch viewResultType {
case .open:
// Open promotion view
case .close:
// Close promotion view
}
}
API 參考: HivePromotion:showCustomContents
#import <HIVEService/HIVEService-Swift.h>
HIVEPromotionCustomType type = HIVEPromotionCustomTypeBOARD;
NSString *contentsKey = @"12345";
[HIVEPromotion showCustomContents: type contents: contentsKey handler: ^(HIVEResultAPI *result, HIVEPromotionViewResultType viewResultType) {
if (![result isSuccess]) {
return;
}
// call successful
switch (viewResultType) {
case HIVEPromotionViewResultTypeOpen:
// Open promotion view
break;
case HIVEPromotionViewResultTypeClose:
// Close promotion view
break;
}
}];
位置橫幅¶
您可以在遊戲中的特定位置或時間顯示全幅橫幅,這稱為點位橫幅。要使用點位橫幅,請在控制台 > 推廣 > 活動註冊 > 點位橫幅中註冊並配置它。
要顯示廣告橫幅,請根據以下指導設置參數,並調用Promotion類的showCustomContents()
方法。
- 將
customType
參數設置為PromotionCustomType.SPOT
。 - 要顯示常規全幅橫幅,將
contentsKey
參數設置為 控制台 > 促銷 > 活動設置 > 遊戲設置 > 橫幅標籤 > 活動管理名稱 > 橫幅 ID。 - 要顯示交叉促銷全廣告,將
contentsKey
參數設置為ad
。您可以使用橫幅在所需的時機顯示交叉促銷全廣告。
Warning
使用 contentsKey
的橫幅和廣告顯示功能僅在已應用Hive SDK v4的應用程式中可用。
這裡是一個實現即時橫幅的示例代碼。
API 參考: hive.Promotion.showCustomContents
using hive;
PromotionCustomType customType = PromotionCustomType.SPOT;
String contentsKey = "12345";
Promotion.showCustomContents(customType, contentsKey, (ResultAPI result, PromotionEventType viewEventType) => {
if (!result.isSuccess()) {
return;
}
// call successful
switch (viewEventType) {
case OPEN:
// Open promotion view
break;
case CLOSE:
// Close promotion view
break;
}
});
#include "HivePromotion.h"
EHivePromotionCustomType PromotionCustomType = EHivePromotionCustomType::SPOT;
FString ContentsKey = TEXT("12345");
FHivePromotion::ShowCustomContents(PromotionCustomType, ContentsKey, FHivePromotionViewDelegate::CreateLambda([this](const FHiveResultAPI& Result, const EHivePromotionEventType& PromotionEventType) {
if (!Result.IsSuccess()) {
return;
}
// API 呼叫成功
switch (PromotionEventType) {
case EHivePromotionEventType::OPEN:
// 開啟促銷視圖
case EHivePromotionEventType::CLOSE:
// 促銷視圖關閉
break;
default:
// 關閉促銷視圖
break;
}
}));
API 參考: Promotion::showCustomContents
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
PromotionCustomType customType = PromotionCustomType::SPOT;
string contentsKey = "12345";
Promotion::showCustomContents(customType, contentsKey, [=](ResultAPI result, PromotionEventType viewEventType) {
if (!result.isSuccess()) {
return;
}
// call successful
switch (viewEventType) {
case OPEN:
// Open promotion view
break;
case CLOSE:
// Close promotion view
break;
}
});
API 參考: Promotion.showCustomContents
import com.hive.Promotion
import com.hive.ResultAPI
val promotionCustomType = Promotion.PromotionCustomType.SPOT
val contentsKey = "12345"
Promotion.showCustomContents(promotionCustomType, contentsKey, object : Promotion.PromotionViewListener {
override fun onPromotionView(result: ResultAPI, promotionEventType: Promotion.PromotionViewResultType) {
if (!result.isSuccess) {
return
}
// call successful
when (promotionEventType) {
Promotion.PromotionViewResultType.OPENED -> {
// Open promotion view
}
Promotion.PromotionViewResultType.CLOSED -> {
// Close promotion view
}
}
}
})
API 參考: com.hive.Promotion.showCustomContents
import com.hive.Promotion;
import com.hive.ResultAPI;
Promotion.PromotionCustomType promotionCustomType = Promotion.PromotionCustomType.SPOT;
String content_key = "12345";
Promotion.INSTANCE.showCustomContents(promotionCustomType, content_key, (result, viewResultType) -> {
if (!result.isSuccess()) {
return;
}
// call successful
switch (viewResultType) {
case OPENED:
// Open promotion view
break;
case CLOSED:
// Close promotion view
break;
}
});
API 參考: PromotionInterface.showCustomContents
import HIVEService
let type = PromotionCustomType.spot
let contentsKey = "12345"
PromotionInterface.showCustomContents(type, contents: contentsKey) { result, viewResultType in
if !result.isSuccess() {
return
}
// call successful
switch viewResultType {
case .open:
// Open promotion view
case .close:
// Close promotion view
}
}
API 參考: HivePromotion:showCustomContents
#import <HIVEService/HIVEService-Swift.h>
HIVEPromotionCustomType type = HIVEPromotionCustomTypeSPOT;
NSString *contentsKey = @"12345";
[HIVEPromotion showCustomContents: type contents: contentsKey handler: ^(HIVEResultAPI *result, HIVEPromotionViewResultType viewResultType) {
if (![result isSuccess]) {
return;
}
// call successful
switch (viewResultType) {
case HIVEPromotionViewResultTypeOpen:
// Open promotion view
break;
case HIVEPromotionViewResultTypeClose:
// Close promotion view
break;
}
}];
[su_divider text="⇡ Go to top" divider_color="#65737e" link_color="#65737e" size="1"]
直接視圖¶
直接視圖是一個功能,可以從遊戲中調用在 Hive 控制台上註冊的活動編號並直接顯示。當您在遊戲中調用在 Hive 控制台中註冊的活動 ID 時,對應的內容將作為框架或全屏顯示。 從 Hive SDK 4.16.0 開始,您可以根據在 Hive 控制台的 促銷 > 活動設置 中設置的曝光類型以全屏或框架類型顯示。
要顯示直接視圖,請按照以下說明設置參數,然後在Promotion類中調用showCustomContents()
方法。
- 將 customType 設置為
PromotionCustomType.DIRECT
參數。 將 contentsKey 參數設置為 活動編號 在 Hive 控制台 > 推廣 > 活動設置 > 普通橫幅標籤*。
以下是創建直接視圖的示例代碼。
API 參考: hive.Promotion.showCustomContents
using hive;
PromotionCustomType customType = PromotionCustomType.DIRECT;
String contentsKey = "12345";
Promotion.showCustomContents(customType, contentsKey, (ResultAPI result, PromotionEventType viewEventType) => {
if (!result.isSuccess()) {
return;
}
// call success
switch (viewEventType) {
case OPEN:
// Open promotion view
break;
case CLOSE:
// Close promotion view
break;
}
});
#include "HivePromotion.h"
EHivePromotionCustomType PromotionCustomType = EHivePromotionCustomType::DIRECT;
FString ContentsKey = TEXT("12345");
FHivePromotion::ShowCustomContents(PromotionCustomType, ContentsKey, FHivePromotionViewDelegate::CreateLambda([this](const FHiveResultAPI& Result, const EHivePromotionEventType& PromotionEventType) {
if (!Result.IsSuccess()) {
return;
}
// API 呼叫成功
switch (PromotionEventType) {
case EHivePromotionEventType::OPEN:
// 開啟促銷視圖
break;
case EHivePromotionEventType::CLOSE:
// 關閉促銷視圖
break;
default:
// 其他事件發生
break;
}
}));
API 參考: Promotion::showCustomContents
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
PromotionCustomType customType = PromotionCustomType::DIRECT;
string contentsKey = "12345";
Promotion::showCustomContents(customType, contentsKey, [=](ResultAPI result, PromotionEventType viewEventType) {
if (!result.isSuccess()) {
return;
}
// call successful
switch (viewEventType) {
case OPEN:
// Open promotion view
break;
case CLOSE:
// Close promotion view
break;
}
});
API 參考: Promotion.showCustomContents
import com.hive.Promotion
import com.hive.ResultAPI
val promotionCustomType = Promotion.PromotionCustomType.DIRECT
val contentsKey = "12345"
Promotion.showCustomContents(promotionCustomType, contentsKey, object : Promotion.PromotionViewListener {
override fun onPromotionView(result: ResultAPI, promotionEventType: Promotion.PromotionViewResultType) {
if (!result.isSuccess) {
return
}
// call successful
when (promotionEventType) {
Promotion.PromotionViewResultType.OPENED -> {
// Open promotion view
}
Promotion.PromotionViewResultType.CLOSED -> {
// Close promotion view
}
}
}
})
API 參考: com.hive.Promotion.showCustomContents
import com.hive.Promotion;
import com.hive.ResultAPI;
Promotion.PromotionCustomType promotionCustomType = Promotion.PromotionCustomType.DIRECT;
String content_key = "12345";
Promotion.INSTANCE.showCustomContents(promotionCustomType, content_key, (result, viewResultType) -> {
if (!result.isSuccess()) {
return;
}
// call successful
switch (viewResultType) {
case OPENED:
// Open promotion view
break;
case CLOSED:
// Close promotion view
break;
}
});
API 參考: PromotionInterface.showCustomContents
import HIVEService
let type = PromotionCustomType.direct
let contentsKey = "12345"
PromotionInterface.showCustomContents(type, contents : contentsKey) {
result,
viewResultType in
if !result.isSuccess() {
return
}
// call successful
switch viewResultType {
case.open:
// Open promotion view
case.close:
// Close promotion view
}
}
API 參考: HivePromotion:showCustomContents
#import <HIVEService /HIVEService-Swift.h>
HIVEPromotionCustomType type = HIVEPromotionCustomTypeDIRECT;
NSString *contentsKey = @"12345";
[HIVEPromotion showCustomContents: type contents: contentsKey handler: ^(HIVEResultAPI *result,
HIVEPromotionViewResultType viewResultType) {
if (![result isSuccess]) {
return;
}
// call successful
switch (viewResultType) {
case HIVEPromotionViewResultTypeOpen:
// Open promotion view
break;
case HIVEPromotionViewResultTypeClose:
// Close promotion view
break;
}
}];
實作您自己的橫幅¶
Hive SDK 提供了通过 showPromotion
方法将所需的活动作为横幅展示的功能。然而,您可能希望展示一个 Hive SDK 未提供的横幅(滚动横幅),或者您可能希望根据自己的需要自定义并展示 Hive SDK 提供的横幅。 要实现您自己的横幅,您需要遵循以下步骤。
- 註冊要在 Hive 控制台中實施和顯示的橫幅的資訊(橫幅圖片、連結等)。
- 調用 Hive SDK 的 getBannerInfo() 以從 Hive 伺服器獲取實施橫幅所需的資訊。
- 根據接收到的資訊,實施橫幅並在遊戲中顯示它。
Note
Hive SDK 提供了實現橫幅所需的信息,使您可以自定義所有橫幅並直接在遊戲中顯示它們。
滾動橫幅¶
滾動橫幅是一種內容不斷流動的橫幅。要展示滾動橫幅,遊戲工作室必須自行實現並展示它們。
獲取橫幅資訊¶
getBannerInfo
是一個函數,用於獲取在遊戲工作室希望直接實現橫幅時所需的資訊,以便以所需的標準顯示橫幅。當此 API 從 Hive 伺服器獲取配置橫幅的數據時,您的遊戲可以使用這些數據以您想要的方式顯示橫幅。要調用此 API,必須初始化身份驗證 v1 或身份驗證 v4。如果未初始化,則可能會在接收數據時發生問題。
Note
您可以將點擊橫幅時收到的 pid(整數)值轉換為 contentsKey(字符串),並將其作為參數傳遞給 Promotion 類的 showCustomContents()
方法,以將其作為 直接視圖 形式顯示。
API 請求範例¶
API 參考: hive .Promotion.getBannerInfo
using hive;
/*
ALL,
EVENT,
NOTICE,
CROSS (跨横幅)
*/
PromotionCampaignType campaignType = PromotionCampaignType.EVENT;
/*
SMALL (小横幅),
GREAT (大横幅),
ROLLING (滚动横幅)
*/
PromotionBannerType bannerType = PromotionBannerType.ROLLING;
Promotion.getBannerInfo(campaignType, bannerType, (ResultAPI result, List bannerInfoList) => {
if (result.isSuccess()) {
// 调用成功
}
});
// 横幅类型和活动类型也可以通过字符串而不是枚举来调用。
/*
"all" (所有),
"event" (事件),
"notice" (通知),
"cross" (跨大横幅)
*/
String campaignType = "event";
/*
"small" (小横幅),
"great" (大横幅),
"rolling" (滚动横幅)
*/
String bannerType = "rolling";
Promotion.getBannerInfoString(campaignType, bannerType, (ResultAPI result, List bannerInfoList) => {
if (result.isSuccess()) {
// 调用成功
}
});
```c++
include "HivePromotion.h"¶
/*
"所有" (all),
"事件" (event),
"通知" (notice),
"跨越" (Cross Great Banner)
*/
EHivePromotionCampaignType CampaignType = EHivePromotionCampaignType::EVENT;
/*
"小型" (band banner),
"大型" (great banner),
"滾動" (rolling banner)
*/
EHivePromotionBannerType BannerType = EHivePromotionBannerType::ROLLING;
FHivePromotion::GetBannerInfo(CampaignType, BannerType, FHivePromotionOnBannerInfoDelegate::CreateLambda(this { if (Result.IsSuccess()) { // call success } }));
// 橫幅類型和活動類型也可以通過字符串而不是枚舉來調用。
/*
"all" (全部),
"event" (事件),
"notice" (通知),
"cross" (跨越大橫幅)
/
FString CampaignType = TEXT("event"); /
"small" (小橫幅),
"great" (大橫幅),
"rolling" (滾動橫幅)
*/ FString BannerType = TEXT("rolling");
FHivePromotion::GetBannerInfoString(CampaignType, BannerType, FHivePromotionOnBannerInfoDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TArray<FHivePromotionBannerInfo>& PromotionBannerInfoList) {
if (Result.IsSuccess()) {
// API call success
}
}));
```
API 參考: Promotion ::getBannerInfo
#include <HIVE_SDK_Plugin/HIVE_CPP.h>
using namespace std;
using namespace hive;
/*
ALL,
EVENT,
NOTICE,
CROSS (Cross Banner)
*/
PromotionCampaignType campaignType = PromotionCampaignType::EVENT;
/*
SMALL (band banner),
GREAT (Great Banner),
ROLLING (rolling banner)
*/
PromotionBannerType bannerType = PromotionBannerType::ROLLING;
Promotion::getBannerInfo(campaignType, bannerType, [=](ResultAPI result, vector bannerInfos) {
if (result.isSuccess()) {
// call successful
}
});
// 橫幅類型和活動類型也可以通過字符串而不是枚舉來調用。
/*
"all" (所有),
"event" (事件),
"notice" (通知),
"cross" (跨越大橫幅)
*/
string campaignType = "event";
/*
"small" (小橫幅),
"great" (大橫幅),
"rolling" (滾動橫幅)
*/
string bannerType = "rolling";
Promotion::getBannerInfoString(campaignType, bannerType, [=](ResultAPI result, vector bannerInfos) {
if (result.isSuccess()) {
// call successful
}
});
API 參考: Promotion.getBannerInfo
import com.hive.Promotion
import com.hive.ResultAPI
/*
ALL,
EVENT,
NOTICE,
CROSS (Cross Banner)
*/
val campaignType = Promotion.PromotionCampaignType.EVENT
/*
SMALL (band banner),
GREAT (Great Banner),
ROLLING (rolling banner)
*/
val bannerType = Promotion
.PromotionBannerType
.ROLLING
Promotion
.getBannerInfo(
campaignType,
bannerType,
object : Promotion.PromotionBannerInfoListener {
override fun onReceiveInfo(
result : ResultAPI,
bannerInfoList : ArrayList <Promotion.PromotionBanner>?
) {
if (result.isSuccess) {
// call successful
}
}
}
)
// Banner type and campaign type can also be called through strings instead of
// enumeration.
/*
"all" (all),
"event" (event),
"notice" (notice),
"cross" (Cross Great Banner)
*/
val campaignType = "event"
/*
"small" (band banner),
"great" (great banner),
"rolling" (rolling banner)
*/
val bannerType = "rolling"
Promotion.getBannerInfoString(
campaignType,
bannerType,
object : Promotion.PromotionBannerInfoListener {
override fun onReceiveInfo(
result : ResultAPI,
bannerInfoList : ArrayList <Promotion.PromotionBanner>?
) {
if (result.isSuccess) {
// call successful
}
}
}
)
API 參考: Promotion .INSTANCE.getBannerInfo
import com.hive.Promotion;
import com.hive.ResultAPI;
/*
ALL,
EVENT,
NOTICE,
CROSS (Cross Banner)
*/
Promotion.PromotionCampaignType campaignType = Promotion.PromotionCampaignType.EVENT;
/*
SMALL (band banner),
GREAT (Great Banner),
ROLLING (rolling banner)
*/
Promotion.PromotionBannerType bannerType = Promotion.PromotionBannerType.ROLLING;
Promotion.INSTANCE.getBannerInfo(campaignType, bannerType, (result, bannerInfoList) -> {
if(result.isSuccess()) {
// call successful
}
});
// Banner type and campaign type can also be called through strings instead of enumeration.
/*
"all" (all),
"event" (event),
"notice" (notice),
"cross" (Cross Great Banner)
*/
String campaignType = "event";
/*
"small" (band banner),
"great" (great banner),
"rolling" (rolling banner)
*/
String bannerType = "rolling";
Promotion.INSTANCE.getBannerInfo(campaignType, bannerType, (result, bannerInfoList) -> {
if(result.isSuccess()) {
// call successful
}
});
API 參考: PromotionInterface.getBannerInfo
import HIVEService
/*
all (all),
event(event),
notice,
cross (cross banner)
*/
let campaignType = PromotionCampaignType.event
/*
small (band banner),
great(great banner),
rolling(rolling banner)
*/
let bannerType = PromotionBannerType.rolling
PromotionInterface.getBannerInfo(campaignType, bannerType: bannerType) { result, bannerInfoList in {
if result.isSuccess() {
// call successful
}
}
// 橫幅類型和活動類型也可以通過字符串而不是枚舉來調用。
/*
"all" (全部),
"event" (事件),
"notice" (通知),
"cross" (跨越大橫幅)
*/
let campaignType = "event"
/*
"small" (小橫幅),
"great" (大橫幅),
"rolling" (滾動橫幅)
*/
let bannerType = "rolling"
PromotionInterface.getBannerInfoString(campaignType, bannerString: bannerType) { result, bannerInfoList in {
if result.isSuccess() {
// API call successful
}
}
API 參考: HIVEPromotion getBannerInfo
#import <HIVEService/HIVEService-Swift.h>
/*
HIVEPromotionCampaignTypeAll (全部);
HIVEPromotionCampaignTypeEvent(事件);
HIVEPromotionCampaignTypeNotice(通知);
HIVEPromotionCampaignTypeCross (交叉横幅)
*/
HIVEPromotionCampaignType campaignType = HIVEPromotionCampaignTypeEvent;
/*
HIVEPromotionBannerTypeSmall (小横幅),
HIVEPromotionBannerTypeGreat(大横幅),
HIVEPromotionBannerTypeRolling
*/
HIVEPromotionBannerType bannerType = kHIVEPromotionBannerTypeRolling;
[HIVEPromotion getBannerInfo: campaignType bannerType: bannerType handler: ^(HIVEResultAPI *result, NSArray *bannerInfos) {
if ([result isSuccess]) {
// call successful
}
}];
// 橫幅類型和活動類型也可以通過字符串而不是枚舉來調用。
/*
"all" (全部),
"event" (事件),
"notice" (通知),
"cross" (跨越大橫幅)
*/
NSString *campaignType = @"event";
/*
"small" (小橫幅),
"great" (大橫幅),
"rolling" (滾動橫幅)
*/
NSString *bannerType = @"rolling";
[HIVEPromotion getBannerInfoString: campaignType, bannerString: bannerType, handler: ^(HIVEResultAPI *result, NSArray<HIVEPromotionBanner *> *bannerInfos) {
if ([result isSuccess]) {
// call successful
}
}];
API 回應:PromotionBannerInfo¶
在API響應中,實現橫幅所需的橫幅信息位於PromotionBannerInfo對象(數組)中。詳細信息請參見下表。
字段名稱 | 類型 | 描述 |
---|---|---|
pid | 整數 | 推廣活動 ID |
imageUrl | 字串 | 活動橫幅的圖片 URL |
linkUrl | 字串 | 當用戶點擊活動橫幅時打開的 URL |
displayStartDate | 字串 | 活動的開始時間 |
displayEndDate | 字串 | 活動的結束時間 |
utcStartDate | 整數 | 活動的開始時間 (Unix 時間戳) |
utcEndDate | 整數 | 活動的結束時間 (Unix 時間戳) |
typeLink | 字串 | 當用戶點擊活動橫幅時打開頁面的類型。註冊活動時選擇。 * webview: 打開內部鏈接 * webbrowser: 打開外部鏈接 * market: 打開市場 (應用商店) 頁面 * notice: 打開通知頁面 * text: 打開促銷文本通知 * none: 停留在當前頁面 |
typeBanner | 字串 | 活動橫幅的類型 * great: 插頁橫幅 * small: 普通橫幅 * rolling: 滾動橫幅 |
typeCampaign | 字串 | 推廣的活動類型 * all: 所有 * event: 活動 * notice: 通知 * cross: 跨插頁橫幅 |
interworkData | 字串 | 包含 API 和參數的 JSON 數據,用於將用戶移動到遊戲中的特定位置。這些數據為字串格式。例如,如果用戶點擊自定義的事件滾動橫幅,您可以將該用戶引導到特定事件項目的購買畫面。 |
活動數據搜尋¶
Hive SDK 提供了一個功能,可以搜索在 Hive 控制台上註冊的活動數據。當您直接在遊戲中顯示註冊的活動內容而不是使用促銷視圖時,此功能非常有用。 以下活動類型可供搜索:自定義視圖、自定義板、廣告橫幅和直接視圖。Promotion 類的 showCustomContents()
方法可以解釋這四種類型。
資料表單¶
Hive SDK 返回促銷資訊,使用 PromotionViewInfo
物件陣列,因為廣告橫幅可以包含多個橫幅,例如插頁式廣告。即使自訂視圖、自訂版面和直接視圖包含單一形式,Hive 仍然會以陣列型別返回所有活動的資訊。
以下表格是PromotionViewInfo
物件的組成。
名稱 | 類型 | 描述 |
---|---|---|
url | 字串 | 要由 WebView 加載的頁面 URL |
postString | 字串 | 加載 WebView 所需的 POST 字串 |
資料搜尋¶
要搜索在 Hive 控制台上注册的活动数据,请将促销的唯一 ID 设置为调用 Promotion 类的 getViewInfo()
方法的第一个参数。然后,返回接收活动数据的回调方法。 以下是请求唯一 ID 为 310000 的活动的示例代码。Android 和 iOS 的示例包含直接在 WebView 上显示来自 Hive SDK 的数据的代码。
API 參考: hive.Promotion.getViewInfo
#include "HivePromotion.h"
EHivePromotionCustomType PromotionCustomType = EHivePromotionCustomType::VIEW;
FString ContentsKey = TEXT("123456");
FHivePromotion::GetViewInfo(PromotionCustomType,
ContentsKey,
FHivePromotionOnViewInfoDelegate::CreateLambda([this](const FHiveResultAPI& Result, const TArray<FHivePromotionViewInfo>& PromotionViewInfoList) {
if (Result.IsSuccess()) {
// API call success
}
}));
API 參考: Promotion::getViewInfo
#include <HIVE_SDK_Plugin/HIVE_CPP.h> using namespace std;
using namespace hive;
PromotionCustomType customType = PromotionCustomType::VIEW;
string contentsKey = "123456";
Promotion::getViewInfo(
customType,
contentsKey,
[=](ResultAPI result, vector promotionViewInfo) {
if (result.isSuccess()) {
// call successful
}
}
);
API 參考: Promotion.getViewInfo
import com.hive.Promotion
import com.hive.ResultAPI
val customType = Promotion.PromotionCustomType.VIEW
val contentsKey = "123456"
Promotion.getViewInfo(customType, contentsKey, object : Promotion.PromotionViewInfoListener {
override fun onReceiveInfo(result: ResultAPI, viewInfo: ArrayList<Promotion.PromotionViewInfo>?) {
if (result.isSuccess) {
// call successful
}
}
})
API 參考: com.hive.Promotion.getViewInfo
import com.hive.Promotion;
import com.hive.ResultAPI;
Promotion.PromotionCustomType promotionCustomType = Promotion.PromotionCustomType.VIEW;
String contentsKey = "123456";
Promotion.INSTANCE.getViewInfo(promotionCustomType, contentsKey, (result, viewInfo) -> {
if (result.isSuccess()) {
// call successful
}
});
API 參考: PromotionInterface.getViewInfo
API 參考: HIVEPromotion:getViewInfo
#import <HIVEService/HIVEService-Swift.h>
HIVEPromotionCustomType promotionType = HIVEPromotionCustomTypeVIEW;
NSString *contentsKey = @"123456";
[HIVEPromotion getViewInfo: promotionType contents: contentsKey handler: ^(HIVEResultAPI *result, NSArray<HIVEPromotionViewInfo *> *infos) {
if ([result isSuccess]) {
// call successful
}
}];
發送額外信息到促銷伺服器¶
這裡的附加資訊是由您的遊戲公司定義的自訂數據。遊戲公司可以將附加資訊轉發到推廣伺服器,並根據遊戲公司與 Com2uS 平台之間的合作關係用於各種服務。例如,您可以在 additionalInfo
中定義您遊戲的玩家角色等級資訊,如下所示。
在使用 setAdditionalInfo
方法將上述 additionalInfo
發送到推廣伺服器後,請與 Com2uS 平台合作以了解實施細節。例如,當顯示特定事件頁面(直接視圖、自定義視圖 等)時,可以為擁有等級高於 50 的遊戲角色的用戶顯示一個金色邊框的事件橫幅。 您還可以將其用作功能,通過在 additionalInfo
中輸入活動編號來將禮品盒圖像添加到新聞橫幅。
以下是一个传递 additionalInfo
的示例代码。
API 參考: hive.Promotion.setAdditionalInfo
API 參考: Promotion::setAdditionalInfo
API 參考: Promotion.setAdditionalInfo
API 參考: HIVEPromotion::setAdditionalInfo
附加信息可用于所有 Hive SDK 促销功能。因此,在实现任何促销功能之前,我们建议您在定义附加信息及其使用方式后,首先调用 setAdditionalInfo
。
無標題的事件顯示¶
您可以在从插页横幅、Spot Banner、新闻页面或直接视图链接的事件页面上删除 Hive 标题栏。要在没有 Hive 标题栏的情况下显示事件页面,请在调用 showCustomContents()
方法之前调用 Promotion 类的 setAdditionalInfo
方法,将标题字段设置为 Off
。您可以通过整理 additionalInfo 并将其发送到 Hive 服务器来从公开页面中删除 Hive 标题栏,具体如下所述。
以下是釋放標題欄的示例代碼。
API 參考: hive.Promotion.setAdditionalInfo
API 參考: Promotion::setAdditionalInfo
API 參考: Promotion.setAdditionalInfo
API 參考: HIVEPromotion setAdditionalInfo
在促銷中播放視頻片段¶
在您的遊戲推廣中顯示視頻片段,使用 Hive SDK v4.7.0 及更高版本。如果用戶點擊播放鏈接,則會顯示全屏視頻。為此,請確保編碼在播放視頻之前將音量降低,並在播放後將音量提高的功能。
- 顯示視頻片段前後的狀態會發送到實現促銷的 API 處理程序。StartPlayback、FinishPlayback 被發送到
PromotionViewResultType
;而 kPromotionStartPlayback、kPromotionFinishPlayback 則發送到結果 API 代碼的部分。- WebKit.framework 和 libz.tbd 是新增到 iOS Xcode 的框架。
以下是控制遊戲音量以在促銷頁面上播放視頻片段的示例代碼。
API 參考: onPromotionView
using hive;
public void onPromotionViewCB(
ResultAPI result,
PromotionEventType viewEventType
) {
if (!result.isSuccess()) {
return;
}
// call successful
switch (viewEventType) {
case OPEN:
// Open promotion view
break;
case CLOSE:
// Close promotion view
break;
case START_PLAYBACK:
// TODO: Mute game sound
break;
case FINISH_PLAYBACK:
// TODO: Resume game sound
break;
}
}
auto PromotionViewDelegate = FHivePromotionViewDelegate::CreateLambda([this](const FHiveResultAPI& Result, const EHivePromotionEventType& PromotionEventType) {
if (!Result.IsSuccess()) {
return;
}
// API 呼叫成功
switch (PromotionEventType) {
case EHivePromotionEventType::OPEN:
// 開啟促銷視圖
break;
case EHivePromotionEventType::CLOSE:
// 關閉促銷視圖
break;
case EHivePromotionEventType::START_PLAYBACK:
// TODO: 靜音遊戲聲音
break;
case EHivePromotionEventType::FINISH_PLAYBACK:
// TODO: 恢復遊戲聲音
break;
default:
// 恢復遊戲聲音
break;
}
});
API 參考: onPromotionView
#include <HIVE_SDK_Plugin/HIVE_CPP.h> using namespace std;
using namespace hive;
void PromotionTest::onPromotionView(
ResultAPI result,
PromotionEventType viewEventType
) {
if (!result.isSuccess()) {
return;
}
// call successful
switch (viewEventType) {
case OPEN:
// Open promotion view
break;
case CLOSE:
// Close promotion view
break;
case START_PLAYBACK:
// TODO: Mute game sound
break;
case FINISH_PLAYBACK:
// TODO: Resume game sound
break;
}
}
API 參考: onPromotionView
import com.hive.Promotion
import com.hive.ResultAPI
val listener = object: Promotion.PromotionViewListener {
override fun onPromotionView(result: ResultAPI, promotionEventType: Promotion.PromotionViewResultType) {
if (!result.isSuccess) {
return
}
// call successful
when (promotionEventType) {
Promotion.PromotionViewResultType.OPENED -> {
// Open promotion view
}
Promotion.PromotionViewResultType.CLOSED -> {
// Close promotion view
}
Promotion.PromotionViewResultType.START_PLAYBACK -> {
// TODO: Mute game sound
}
Promotion.PromotionViewResultType.FINISH_PLAYBACK -> {
// TODO: Resume game sound
}
else -> {}
}
}
}
API 參考: Promotion .PromotionViewListener
import com.hive.Promotion;
import com.hive.ResultAPI;
Promotion.PromotionViewListener listener = (result, promotionEventType) -> {
if (!result.isSuccess()) {
return;
}
// call successful
switch (promotionEventType) {
case OPENED:
// Open promotion view
break;
case CLOSED:
// Close promotion view
break;
case START_PLAYBACK:
// TODO: Mute game sound
break;
case FINISH_PLAYBACK:
// TODO: Resume game sound
break;
default:
break;
}
};
API 參考: PromotionViewHandler
import HIVEService
let handler = {
(result : ResultAPI, viewResultType : PromotionViewResultType) in if !result.isSuccess() {
return
}
// call successful
switch viewResultType {
case.open:
// Open promotion view
case.close:
// Close promotion view
case.startPlayBack:
// TODO: Mute game sound
case.finishPlayBack:
// TODO: Resume game sound
}
}
API 參考: HIVEPromotionViewHandler
#import <HIVEService/HIVEService-Swift.h>
HIVEPromotionViewHandler handler = ^(HIVEResultAPI* result, HIVEPromotionViewResultType viewResultType) {
if (![result isSuccess]) {
return;
}
// call successful
switch (viewResultType) {
case HIVEPromotionViewResultTypeOpen:
// Open promotion view
break;
case HIVEPromotionViewResultTypeClose:
// Close promotion view
break;
case HIVEPromotionViewResultTypeStartPlayback:
// TODO: Mute game sound
break;
case HIVEPromotionViewResultTypeFinishPlayback:
// TODO: Resume game sound
break;
}
}
};