抖音开放平台Logo
开发者文档
控制台
  • API 概览
  • 开放能力
  • 基础
  • 渲染
  • 设备
  • 文件
  • 位置
  • 媒体
  • 网络
  • 游戏转发分享
  • 实时语音
  • 数据缓存
  • 系统
  • 广告
  • tt.createBannerAd
  • tt.createRewardedVideoAd
  • tt.createInterstitialAd
  • BannerAd
  • BannerAd
  • BannerAd.show
  • BannerAd.hide
  • BannerAd.onLoad
  • BannerAd.offLoad
  • BannerAd.onError
  • BannerAd.offError
  • BannerAd.onResize
  • BannerAd.offResize
  • BannerAd.destroy
  • RewardedVideoAd
  • InterstitialAd
  • 界面
  • 支付
  • Worker
  • BannerAd.show
    收藏
    我的收藏

    基础库 1.3.0 开始支持本方法,这是一个同步方法。

    广告创建后默认是隐藏的,可以通过该方法显示广告。 该方法返回一个 Promise 对象。当广告组件正常获取素材时,该 Promise 对象会是一个 resolved Promise。当广告组件发生错误时,会是一个 rejected Promise,参数与 error 事件监听器获得的参数相同。

    前提条件
    业务背景
    使用限制
    注意事项

    必须调用 BannerAd.onLoad 监听广告素材成功拉取后才能调用 BannerAd.show,否则广告将无法及时展示

    相关教程

    语法

    BannerAd.show()

    参数说明

    返回值

    类型说明最低支持版本
    Promise

    Promise 对象

    1.3.0

    错误码

    errNoerrMsg说明最低支持版本
    2002Just shown an Ad, can't show now!
    1.3.0
    10301feature is not supported in app
    1.3.0
    21300context exception
    小游戏框架内部错误,有需要请创建工单咨询
    1.3.0
    1003current activity is null, can not create game banner
    1.3.0
    1003Please apply for an adUnitId
    1.3.0
    1003can not create game banner
    小游戏框架内部错误,有需要请创建工单咨询
    1.3.0
    1006The scene does not support advertising
    1.3.0
    1001The adUnitId is empty
    1.3.0
    1008The adUnitId is closed
    1.3.0
    1007The adUnitId is prohibit
    1.3.0
    1002The adUnitId is invalid
    1.3.0
    20000internal error
    小游戏框架内部错误,有需要请创建工单咨询
    1.3.0
    21000Just shown an Ad, can't show now!
    1.3.0
    21101GridGamePanel with the same gridCount can show most one
    重复报 callback & event
    1.3.0
    21000The banner advertisement has triggered fallback, but fallback ad has shown too many times today
    重复报
    1.3.0
    1003The banner advertisement for current adUnitId hasn't completed loading
    1.3.0
    21000ad is not loaded, try call `show` in `onLoad` method
    重复报
    1.3.0
    21000ad not found
    1.3.0
    21000unitid is illegal
    1.3.0
    21000unitid is illegal
    1.3.0
    21000unitid is illegal
    1.3.0
    21000unitid is illegal
    1.3.0
    21000unitid is illegal
    1.3.0
    21000unitid is illegal
    小游戏框架内部错误,有需要请创建工单咨询
    1.3.0
    1003The banner advertisement for current adUnitId doesn't exist
    1.3.0
    1003The adUnitId is empty
    1.3.0
    1003The adUnitId is invalid
    1.3.0
    1003unknown ad type
    1.3.0
    1002The adUnitId is invalid
    小游戏框架内部错误,有需要请创建工单咨询
    1.3.0
    21000type is illegal param
    小游戏框架内部错误,有需要请创建工单咨询
    1.3.0
    21000app has enter background
    1.3.0

    代码示例

    const bannerAd = tt.createBannerAd({ adUnitId: "xxxx", }); bannerAd.onLoad(() => { bannerAd .show() .then(() => { console.log("广告显示成功"); }) .catch((err) => { console.log("广告组件出现问题", err); }); });