4***@qq.com
4***@qq.com
  • 发布:2023-11-04 17:59
  • 更新:2025-01-08 13:25
  • 阅读:411

微信小程序使用api创建激励视频广告,一直报no ad unit id

分类:uni-app

onError event {errMsg: "no ad unit id"}

代码块

onReady() {  
            // 创建广告  
            const rewardedVideoAd = this.rewardedVideoAd = uni.createRewardedVideoAd({  
                adpid: '1849137715',  
            })  
            rewardedVideoAd.onLoad(() => {  
                console.log('onLoad event')  
            })  
            rewardedVideoAd.onError((err) => {  
                console.log('onError event', err)  
            })  
            rewardedVideoAd.onClose((res) => {  
                console.log('onClose event', res)  
            })  
        },  
        methods: {  
            ggplay() {  
                const rewardedVideoAd = this.rewardedVideoAd;  
                rewardedVideoAd.show()  
                .catch(() => {  
                        rewardedVideoAd.load()  
                        .then(() => rewardedVideoAd.show())  
                        .catch(err => {  
                            console.log('激励广告播放失败')  
                        })  
                })  
            }  
        }
2023-11-04 17:59 负责人:无 分享
已邀请:
jikeshuju

jikeshuju

目前也碰到这个问题,请问解决了吗?

  • zmao

    我也遇到了,请问怎么解决呢?

    2025-01-08 11:59

  • jikeshuju

    回复 2***@qq.com: 直接使用文档中推荐的方法就可以了,不要自己写JS

    2025-02-02 13:37

zmao

zmao

搜了下,这个API需要穿入 adUnitId, 就是广告单元ID,是从广告平台上申请获取到的ID。如果是微信小程序就在微信管理后台 > 流量主 > 广告位ID 获取即可

  • jikeshuju

    微信没有达到开通的条件,才使用的这个方式

    2025-02-02 13:38

要回复问题请先登录注册