收藏
回答

插屏广告无法正常显示

之前接入了激励视频广告,展示完全正常;最近接入插屏广告调用show()之后无法正常显示

加载插屏广告:

public loadInterstitialAd(adUnitId: string) {
    if (!this._sdk) { return; }
    let interstitialAd
    if (!this.interAdInstance) {
        interstitialAd = this.interAdInstance = this._sdk.createInterstitialAd({
            adUnitId: adUnitId
        })
    } else {
        interstitialAd = this.interAdInstance
    }


    if (interstitialAd != null) {
        interstitialAd.offLoad()
        interstitialAd.onLoad(() => {
            console.log("wx interstitialAd onLoad")
        })
        interstitialAd.load()
    }
}


展示插屏广告

public createInterstitialAd(showCallback?: Function, endCallback?: Function) {
    if (!this._sdk) {
        console.warn("wx 不是微信环境,不加载广告")
        showCallback && showCallback()
        endCallback && endCallback(false)
        return null;
    };
    showCallback && showCallback()
    //检测一下网络状态,才能从断网状态中恢复
    this._sdk.getNetworkType().then((res: WechatMinigame.GetNetworkTypeSuccessCallbackResult) => {
        console.log("wx getNetworkType:", res);
    })


    let interstitialAd
    if (!this.interAdInstance) {
        interstitialAd = this.interAdInstance = this._sdk.createInterstitialAd({
            adUnitId: AD_UNIT_ID_INTERSTITIAL
        })
    } else {
        interstitialAd = this.interAdInstance
    }
    let self = this
    if (interstitialAd != null) {
        interstitialAd.offError()
        interstitialAd.onError(res => {
            console.log("wx interstitialAd onError:", res);
            endCallback && endCallback(false);
        });
        interstitialAd.offClose()
        interstitialAd.onClose(res => {
            console.log("wx interstitialAd onClose:", res);
            endCallback && endCallback(res != null && res.errMsg != null);
            AudioMgr.resumeMusic()
        });
        let promise: Promise = interstitialAd.show()
        console.log("wx interstitialAd show")
        promise.then(() => {
            console.log("wx interstitialAd showCallback");
        }).catch(res => {
            console.log("wx interstitialAd show error:", res);
            endCallback && endCallback(false);
            interstitialAd.load()
        }).finally(() => {
            console.log("wx interstitialAd show finally")
        })
        return interstitialAd;
    }
}


几率性出现,当某次加载卡在show的时候,show()方法的promise不会返回,then,catch,finally都没有回调,之后再调用show()都无法加载广告,报错2003插屏广告正在展示中,但其实是没有加载出来的。

有没有人遇到这种情况?

最后一次编辑于  04-11
回答关注问题邀请回答
收藏

1 个回答

  • 维Lee是图
    维Lee是图
    04-14

    过了一个周末来重新试了下,好像又不会出现这样的问题了。。。

    04-14
    有用
    回复
登录 后发表内容