添加抖音广告
This commit is contained in:
parent
8b763f9c93
commit
f4df902592
|
|
@ -3834,6 +3834,33 @@ export default class JiaZai extends cc.Component {
|
|||
}
|
||||
}
|
||||
|
||||
// 抖音广告测试
|
||||
// adShow() {
|
||||
// let overData = {
|
||||
// ad_placement_name: "1001", //内部广告位名称
|
||||
// current_page: "HomeScene" //所在页面
|
||||
// }
|
||||
// var self = this;
|
||||
|
||||
// var callback = function (isType) {
|
||||
// // self.reviewState = false;
|
||||
// if (isType) {
|
||||
// console.log("领取奖励");
|
||||
// cc.fx.GameTool.changeCoin(66666);
|
||||
// this.updateCoin();
|
||||
// } else {
|
||||
// // self.runRewive(data);
|
||||
// }
|
||||
|
||||
// }
|
||||
// console.log("复活");
|
||||
// //@ts-ignore
|
||||
// if (typeof tt !== 'undefined' && tt !== null) {
|
||||
// console.log("复活广告")
|
||||
// cc.fx.GameTool.onShowVideo(callback, overData)
|
||||
// }
|
||||
// }
|
||||
|
||||
update(dt) {
|
||||
if (this.newbieGift && this.monthlyCardNode) {
|
||||
if (this.monthlyCardNode.active == true) {
|
||||
|
|
|
|||
|
|
@ -419,7 +419,6 @@ export namespace MiniGameSdk {
|
|||
|
||||
if (!isWechat() && !isBytedance()) {
|
||||
callback(EAdVideoResult.ACCEPT, 1);
|
||||
this._adVideo = null;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -460,10 +459,12 @@ export namespace MiniGameSdk {
|
|||
this._cleanup();
|
||||
callback(result, count);
|
||||
}
|
||||
|
||||
let adUnitId = cc.fx.GameTool.getAdUnitId();
|
||||
let responseData = {
|
||||
ad_type: "激励视频", //广告类型
|
||||
ad_placement_name: video_data?.ad_placement_name || "", //内部广告位名称 //2000复活 道具 2001 2002 2003
|
||||
ad_placement_id: "adunit-aa9a28e1631bf16f", //内部广告位ID
|
||||
ad_placement_id: adUnitId, //内部广告位ID
|
||||
current_page: video_data?.current_page || "", //所在页面
|
||||
error_detail_info: "", //错误信息
|
||||
error_detail_code: "", //错误码
|
||||
|
|
@ -538,7 +539,7 @@ export namespace MiniGameSdk {
|
|||
let showData = {
|
||||
ad_type: "激励视频", //广告类型
|
||||
ad_placement_name: video_data?.ad_placement_name || "", //内部广告位名称 //2000复活 道具 2001 2002 2003
|
||||
ad_placement_id: "adunit-aa9a28e1631bf16f", //内部广告位ID
|
||||
ad_placement_id: adUnitId, //内部广告位ID
|
||||
current_page: video_data?.current_page || "", //所在页面
|
||||
error_detail_info: "", //错误信息
|
||||
error_detail_code: "", //错误码
|
||||
|
|
|
|||
|
|
@ -1871,10 +1871,11 @@ var GameTool = {
|
|||
}
|
||||
}
|
||||
}
|
||||
let adUnitId = this.getAdUnitId();
|
||||
let requestData = {
|
||||
ad_type: "激励视频", //广告类型
|
||||
ad_placement_name: videoData.ad_placement_name, //内部广告位名称 1001 双倍金币
|
||||
ad_placement_id: "adunit-aa9a28e1631bf16f", //内部广告位ID
|
||||
ad_placement_id: adUnitId, //内部广告位ID
|
||||
current_page: videoData.current_page, //所在页面
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("ad_request", requestData);
|
||||
|
|
@ -1887,7 +1888,7 @@ var GameTool = {
|
|||
callback(false);
|
||||
}, 6000); // 6秒超时
|
||||
cc.fx.GameTool.waitForAdPreload().then(() => {
|
||||
MiniGameSdk.AdvertManager.instance.showVideo('adunit-aa9a28e1631bf16f', videoData, (res: MiniGameSdk.EAdVideoResult, count: number) => {
|
||||
MiniGameSdk.AdvertManager.instance.showVideo(adUnitId, videoData, (res: MiniGameSdk.EAdVideoResult, count: number) => {
|
||||
if (timeoutId) clearTimeout(timeoutId);
|
||||
console.log('用户看的视频广告个数是:', count);
|
||||
console.log('用户观看视频广告结果:', res);
|
||||
|
|
@ -1897,7 +1898,7 @@ var GameTool = {
|
|||
let data = {
|
||||
ad_type: "激励视频", //广告类型
|
||||
ad_placement_name: videoData.ad_placement_name, //内部广告位名称 //2000复活 道具 2001 2002 2003
|
||||
ad_placement_id: "adunit-aa9a28e1631bf16f", //内部广告位ID
|
||||
ad_placement_id: adUnitId, //内部广告位ID
|
||||
current_page: videoData.current_page, //所在页面
|
||||
ad_duration: duration, //广告展示时长
|
||||
ad_play_duration: 30, //广告播放时长
|
||||
|
|
@ -1909,19 +1910,19 @@ var GameTool = {
|
|||
MiniGameSdk.API.showToast('用户看完广告,可以奖励');
|
||||
cc.fx.GameTool.shushu_Track("ad_close", data);
|
||||
callback(true, "ad");
|
||||
// cc.fx.GameTool.preloadRewardedVideoAd(true);
|
||||
cc.fx.GameTool.preloadRewardedVideoAd(true);
|
||||
break;
|
||||
case MiniGameSdk.EAdVideoResult.REJECT:
|
||||
data.is_complete_play = false;
|
||||
MiniGameSdk.API.showToast('广告中断,未获得奖励');
|
||||
cc.fx.GameTool.shushu_Track("ad_close", data);
|
||||
callback(false);
|
||||
// cc.fx.GameTool.preloadRewardedVideoAd(true);
|
||||
cc.fx.GameTool.preloadRewardedVideoAd(true);
|
||||
break;
|
||||
case MiniGameSdk.EAdVideoResult.ERROR:
|
||||
MiniGameSdk.API.showToast('广告加载失败,请稍后再试');
|
||||
callback(false);
|
||||
// cc.fx.GameTool.preloadRewardedVideoAd(true);
|
||||
cc.fx.GameTool.preloadRewardedVideoAd(true);
|
||||
|
||||
break;
|
||||
default:
|
||||
|
|
@ -1957,7 +1958,8 @@ var GameTool = {
|
|||
setTimeout(() => {
|
||||
try {
|
||||
// 预加载激励视频广告
|
||||
const preloadPromise = MiniGameSdk.AdvertManager.instance.preloadVideo('adunit-aa9a28e1631bf16f');
|
||||
const adUnitId = this.getAdUnitId();
|
||||
const preloadPromise = MiniGameSdk.AdvertManager.instance.preloadVideo(adUnitId);
|
||||
|
||||
// 添加超时处理,避免预加载Promise永远处于pending状态
|
||||
const preloadTimeout = setTimeout(() => {
|
||||
|
|
@ -2544,5 +2546,13 @@ var GameTool = {
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
getAdUnitId() {
|
||||
// @ts-ignore
|
||||
let isWeChat = typeof wx !== 'undefined' && wx !== null && cc.sys.platform === cc.sys.WECHAT_GAME;
|
||||
let adUnitId = isWeChat ? 'adunit-aa9a28e1631bf16f' : '4226lb9ea4il1dmjl8';
|
||||
return adUnitId;
|
||||
},
|
||||
|
||||
};
|
||||
export { GameTool };
|
||||
Loading…
Reference in New Issue
Block a user