vivominigame / issues

vivo小游戏问题反馈和统一回复入口
13 stars 9 forks source link

调用banner api之后banner不显示,也没有error报错信息 #172

Open lischolar opened 4 years ago

lischolar commented 4 years ago

调用banner api 之后不显示,也没有error返回

vivo 1058 我们这边先用的phaser 2.6适配的微信小游戏,没问题之后,用咱们提供的工具http://minigame.vivo.com.cn/documents/#/lesson/base/weixin转成vivo,在对接其他广告的时候没有问题,例如:激励适配,正常调用,在对接banner的时候就会出问题,banner不显示,也没有error返回。以下是我的代码逻辑以及运行结果: 代码逻辑: console.log('=====ad banner====');

this.bannerAd = qg.createBannerAd({
  posId: '0e4b46ea781d4b1d985a152d3e7bd6cd',
  style: style
});
console.log('=====ad 60====',this.bannerAd);

var adshow = this.bannerAd && this.bannerAd.show();
adshow && adshow.then(() => {
        console.log("正在加载===============");
    }).catch( (err) => {
        console.log('广告错误======', err);
    }
);

console.log('=====ad 75====');

运行结果: =====ad banner==== VM12 (no filename):8 ### App Framework ### [trace] create JavaObject for game.banneradfactory.createBannerAd. args={"posId":"0e4b46ea781d4b1d985a152d3e7bd6cd","style":{"width":300,"height":83.33333333333334,"left":990,"top":1005},"adIntervals":""} VM12 (no filename):8 ### App Framework ### [trace] game.banneradfactory.createBannerAd has been called by Sync type. args={}. result={"json":["{\"data\":{\"code\":0,\"content\":{\"result_class_name\":\"com\/vivo\/hybrid\/game\/feature\/ad\/GameBannerAdFeature\",\"result_type\":1,\"result_feature_name\":\"game.bannerad\"}}}"]} VM12 (no filename):8 ### App Framework ### [trace] get game.banneradfactory.createBannerAd JavaObject type::: game.bannerad VM12 (no filename):8 ### App Framework ### [trace] multiton=true VM12 (no filename):8 ### App Framework ### [trace] game.banneradfactory.createBannerAd--多例创建成功 VM12 (no filename):8 ### App Framework ### [trace] create ads instance for game.bannerad & javaObjec.id=38 VM12 (no filename):8 =====ad 60==== c {moduleName: "game.bannerad", javaObject: JavaObject, javaObjectId: 38}moduleName: "game.bannerad"javaObject: JavaObjectfuncList: ""id: 38className: "com/vivo/hybrid/game/feature/ad/GameBannerAdFeature"proto: ObjectjavaObjectId: 38proto: t VM12 (no filename):8 ### App Framework ### [trace] game.bannerad javaObject.id:38 show() VM12 (no filename):8 ### App Framework ### [info] show has been called with 'game.bannerad.show'. javaObject.id=38 args={"action":"show","params":"{}","callback":"a99bf09a-b04b-4a47-93b5-40d2fca7361e"} VM12 (no filename):8 =====ad 75====

lixin-android-developer commented 4 years ago

上述代码有两处导致无法输出正确结果

  1. style: style ->style为一个Object对象,请使用正确的对象
  2. console.log('广告错误======', err); ->此处要打印错误信息需使用 console.log('广告错误======', err.code);

请在开发前仔细阅读开发文档 Banner api链接:https://minigame.vivo.com.cn/documents/#/api/da/banner-da Banner demo链接:https://minigame.vivo.com.cn/documents/#/api/da/banner-da?id=%e5%8f%82%e8%80%83demo