showing Admob banner in Inappbrowser(ionic)

2019-04-10 12:17发布

After some research, I get to know that I can place AdMob ads into an application which is having an Android Webivew. I can able to integrate Banner ads into the apk where the ad is appearing at the bottom as expected.

But once the url loads in the app, I am not able to see the banner. I'd checked in this link (How to show AdMob banner in inappbrowser using Cordova/Ionic) but It is with AngularJS(1) framework, I am looking for the same with Angular(5).

Any help will be appreciated!

1条回答
不美不萌又怎样
2楼-- · 2019-04-10 12:33

This is good read

Here is a code snippet to show banner and Interstitial Advertisement

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { AdMobFree, AdMobFreeBannerConfig, AdMobFreeInterstitialConfig } from '@ionic-native/admob-free';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

    constructor(public navCtrl: NavController, public admob: AdMobFree) {

    }

    showBanner() {

        let bannerConfig: AdMobFreeBannerConfig = {
            isTesting: true, // Remove in production
            autoShow: true
            //id: Your Ad Unit ID goes here
        };

        this.admob.banner.config(bannerConfig);

        this.admob.banner.prepare().then(() => {
            // success
        }).catch(e => console.log(e));

    }

    launchInterstitial() {

        let interstitialConfig: AdMobFreeInterstitialConfig = {
            isTesting: true, // Remove in production
            autoShow: true
            //id: Your Ad Unit ID goes here
        }; 

        this.admob.interstitial.config(interstitialConfig);

        this.admob.interstitial.prepare().then(() => {
            // success
        });

    }

}
查看更多
登录 后发表回答