小程序
小游戏
企业微信
微信支付
扫描小程序码分享
我的小游戏买量人数已经过了1000,流量主已开通,相关广告id也配好了,为什么拉取不了广告 appid:wxdf307b07af8c13d0
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
返回的错误码是什么?
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
一样啊1002 啥情况
public createCustomAD(adUnitId: string, callback?: Function, top?: number) {
console.log("Custom广告");
if (!(cc.sys.platform === cc.sys.WECHAT_GAME)) {
callback && callback(false);
return null;
}
//先通过判断基础版本号再使用
let ret = this.compareVersion(customADVersion);
if (ret < 0) {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后再使用该功能。',
})
let info = wx.getSystemInfoSync();
let width = info.windowWidth;
let height = info.windowHeight;
top = top ? height/2 : 250;
let ad = wx.createCustomAd({
adUnitId: adUnitId,
style: {
left: 0,
top: height - top,
width: width, // 用于设置组件宽度,只有部分模板才支持,如矩阵格子模板
fixed: false // fixed 只适用于小程序环境
});
ad.onLoad((res) => {
if (!ad.isShow) {
console.log('原生模板广告show');
ad.show();
console.log('原生模板广告onLoad', JSON.stringify(res));
ad.onError((errMsg, errCode) => {
callback = null;
console.log('原生模板广告onError' + 'errMsg:', errMsg, 'errCode:', errCode);
ad.onClose((res) => {
console.log('原生模板广告onClose', JSON.stringify(res));
return ad;
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
返回的错误码是什么?
errCode: 5047
errMsg: "no advertisement"
__proto__: Object
console.log("banner广告");
place = place ? ADPLACE.DOWNMID : place;
if (!(cc.sys.platform === cc.sys.WECHAT_GAME)) {
callback && callback(false);
return null;
}
//先通过判断基础版本号再使用
let ret = this.compareVersion(bannerADVersion);
if (ret < 0) {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后再使用该功能。',
})
callback && callback(false);
return null;
}
let ad = wx.createBannerAd({
adUnitId: adUnitId,
adItervals: 30,
style: {
left: 0,
top: 0,
width: 300,
height: 80,
}
});
ad.show();
ad.onError((errMsg, errCode) => {
callback && callback(false);
callback = null;
console.log('拉取广告牌失败' + 'errMsg:', errMsg, 'errCode:', errCode);
})
ad.onResize((size) => {
console.log('resize:', size);
let setSize = this.setBannerPlace(size, place);
ad.style.left = setSize.left;
ad.style.top = setSize.top;
})
return ad;
}
一样啊1002 啥情况
public createCustomAD(adUnitId: string, callback?: Function, top?: number) {
console.log("Custom广告");
if (!(cc.sys.platform === cc.sys.WECHAT_GAME)) {
callback && callback(false);
return null;
}
//先通过判断基础版本号再使用
let ret = this.compareVersion(customADVersion);
if (ret < 0) {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后再使用该功能。',
})
callback && callback(false);
return null;
}
let info = wx.getSystemInfoSync();
let width = info.windowWidth;
let height = info.windowHeight;
top = top ? height/2 : 250;
let ad = wx.createCustomAd({
adUnitId: adUnitId,
style: {
left: 0,
top: height - top,
width: width, // 用于设置组件宽度,只有部分模板才支持,如矩阵格子模板
fixed: false // fixed 只适用于小程序环境
}
});
ad.onLoad((res) => {
if (!ad.isShow) {
console.log('原生模板广告show');
ad.show();
}
console.log('原生模板广告onLoad', JSON.stringify(res));
})
ad.onError((errMsg, errCode) => {
callback && callback(false);
callback = null;
console.log('原生模板广告onError' + 'errMsg:', errMsg, 'errCode:', errCode);
})
ad.onClose((res) => {
console.log('原生模板广告onClose', JSON.stringify(res));
})
ad.show();
return ad;
}