将横幅广告添加到Ionic 2应用

时间:2016-01-13 11:03:16

标签: admob angular ionic2

我一直在尝试为新的离子2应用添加横幅广告,但广告没有显示 我正在这样做

http://pointdeveloper.com/ionic-2-banner-ads-with-admob-pro-plugin/

这是我的app.js文件代码

import {App, Platform, Config} from 'ionic/ionic';
import {TabsPage} from './pages/tabs/tabs';


@App({
  templateUrl: 'build/app.html',
  // Check out the config API docs for more info
  // http://ionicframework.com/docs/v2/api/config/Config/
  config: {
     tabbarPlacement: 'bottom'
  }
})
export class MyApp {
  constructor(platform: Platform) {
    this.root = TabsPage;

    platform.ready().then(() => {
      // Do any necessary cordova or native calls here now that the platform is ready
      var admobid = {};
        // select the right Ad Id according to platform
        if( /(android)/i.test(navigator.userAgent) ) { 
            admobid = { // for Android
                banner: 'ca-app-pub-6869992474017983/9375997553',
                interstitial: 'ca-app-pub-6869992474017983/1657046752'
            };
        } else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) {
            admobid = { // for iOS
                banner: 'ca-app-pub-6869992474017983/4806197152',
                interstitial: 'ca-app-pub-6869992474017983/7563979554'
            };
        } else {
            admobid = { // for Windows Phone
                banner: 'ca-app-pub-6869992474017983/8878394753',
                interstitial: 'ca-app-pub-6869992474017983/1355127956'
            };
        }

  if(window.AdMob) AdMob.createBanner( {
      adId:admobid.banner,
      isTesting:true, 
      position:AdMob.AD_POSITION.BOTTOM_CENTER
     } );
    });
  }
}

2 个答案:

答案 0 :(得分:3)

嘿,我看到你在这里使用我的帖子

http://pointdeveloper.com/ionic-2-banner-ads-with-admob-pro-plugin/

但您需要做的是添加 autoShow:true

所以在你的代码中你需要以下

  if(window.AdMob) AdMob.createBanner( {
      adId:admobid.banner,
      isTesting:true, 
      position:AdMob.AD_POSITION.BOTTOM_CENTER, 
      autoShow:true //this shows the ad
      } );

答案 1 :(得分:0)

我也有问题,横幅有效,但插页式广告崩溃我的应用程序我不知道为什么..

我必须在页面中添加一些内容吗?喜欢参数还是进口?