高级功能提供自定义部分;自定义视图允许您显示所需的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;
}
// 调用成功
switch (viewResultType) {
case HIVEPromotionViewResultTypeOpen:
// 打开促销视图
break;
case HIVEPromotionViewResultTypeClose:
// 关闭促销视图
break;
}
}];
自定义板¶
与一般的推广通知不同,Custom Board 可用于在游戏中显示各种用途的公告板列表。
注册¶
有关创建和注册自定义板的更多信息,请参见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;
}
// 调用成功
switch (viewResultType) {
case HIVEPromotionViewResultTypeOpen:
// 打开促销视图
break;
case HIVEPromotionViewResultTypeClose:
// 关闭促销视图
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;
}
// 调用成功
switch (viewResultType) {
case HIVEPromotionViewResultTypeOpen:
// 打开促销视图
break;
case HIVEPromotionViewResultTypeClose:
// 关闭促销视图
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;
/*
"小" (小型横幅),
"大" (大型横幅),
"滚动" (滚动横幅)
*/
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 调用成功
}
}));
```
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 (跨横幅)
*/
Promotion.PromotionCampaignType campaignType = Promotion.PromotionCampaignType.EVENT;
/*
SMALL (小横幅),
GREAT (大横幅),
ROLLING (滚动横幅)
*/
Promotion.PromotionBannerType bannerType = Promotion.PromotionBannerType.ROLLING;
Promotion.INSTANCE.getBannerInfo(campaignType, bannerType, (result, bannerInfoList) -> {
if(result.isSuccess()) {
// 调用成功
}
});
// 横幅类型和活动类型也可以通过字符串而不是枚举来调用。
/*
"all" (所有),
"event" (事件),
"notice" (通知),
"cross" (跨大横幅)
*/
String campaignType = "event";
/*
"small" (小横幅),
"great" (大横幅),
"rolling" (滚动横幅)
*/
String bannerType = "rolling";
Promotion.INSTANCE.getBannerInfo(campaignType, bannerType, (result, bannerInfoList) -> {
if(result.isSuccess()) {
// 调用成功
}
});
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() {
// 调用成功
}
}
// 横幅类型和活动类型也可以通过字符串而不是枚举来调用。
/*
"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: 打开市场 (App Store) 页面 * 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被发送到Result 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;
}
// 调用成功
switch (viewResultType) {
case HIVEPromotionViewResultTypeOpen:
// 打开促销视图
break;
case HIVEPromotionViewResultTypeClose:
// 关闭促销视图
break;
case HIVEPromotionViewResultTypeStartPlayback:
// TODO: 静音游戏声音
break;
case HIVEPromotionViewResultTypeFinishPlayback:
// TODO: 恢复游戏声音
break;
}
}
};