AdMob Pro

Improve this doc

Plugin for Google Ads, including AdMob / DFP (DoubleClick for publisher) and mediations to other Ad networks.

IMPORTANT NOTICE: this plugin takes a percentage out of your earnings if you profit more than $1,000. Read more about this on the plugin's repo. For a completely free alternative, see AdMobPro Free.

Repo: https://github.com/floatinghotpot/cordova-admob-pro

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-admobpro
    $ npm install --save @ionic-native/admob-pro
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { AdMobPro } from '@ionic-native/admob-pro';
import { Platform } from 'ionic-angular';

constructor(private admob: AdMobPro, private platform: Platform ) { }

ionViewDidLoad() {
  this.admob.onAdDismiss()
    .subscribe(() => { console.log('User dismissed ad'); });
}

onClick() {
  let adId;
  if(this.platform.is('android')) {
    adId = 'YOUR_ADID_ANDROID';
  } else if (this.platform.is('ios')) {
    adId = 'YOUR_ADID_IOS';
  }
  this.admob.prepareInterstitial({adId: adId})
    .then(() => { this.admob.showInterstitial(); });
}

Instance Members

AD_POSITION

createBanner(adIdOrOptions)

Create a banner

Param Type Details
adIdOrOptions string|AdMobOptions

Ad ID or Options

Returns: Promise<any> Returns a Promise that resolves when the banner is created

removeBanner()

Destroy the banner, remove it from screen.

showBanner(position)

Show banner at position

Param Type Details
position number

Position. Use AdMobPro.AD_POSITION to set values.

showBannerAtXY(x, y)

Show banner at custom position

Param Type Details
x number

Offset from screen left.

y number

Offset from screen top.

hideBanner()

Hide the banner, remove it from screen, but can show it later

prepareInterstitial(adIdOrOptions)

Prepare interstitial banner

Param Type Details
adIdOrOptions string|AdMobOptions

Ad ID or Options

Returns: Promise<any> Returns a Promise that resolves when interstitial is prepared

showInterstitial()

Show interstitial ad when it’s ready

prepareRewardVideoAd(adIdOrOptions)

Prepare a reward video ad

Param Type Details
adIdOrOptions string|AdMobOptions

Ad ID or Options

Returns: Promise<any> Returns a Promise that resolves when the ad is prepared

showRewardVideoAd()

Show a reward video ad

setOptions(options)

Sets the values for configuration and targeting

Param Type Details
options AdMobOptions

Options

Returns: Promise<any> Returns a Promise that resolves when the options have been set

getAdSettings()

Get user ad settings

Returns: Promise<any> Returns a promise that resolves with the ad settings

onAdFailLoad()

Triggered when failed to receive Ad

Returns: Observable<any>

onAdLoaded()

Triggered when Ad received

Returns: Observable<any>

onAdPresent()

Triggered when Ad will be showed on screen

Returns: Observable<any>

onAdLeaveApp()

Triggered when user click the Ad, and will jump out of your App

Returns: Observable<any>

onAdDismiss()

Triggered when dismiss the Ad and back to your App

Returns: Observable<any>

AdMobOptions

Param Type Details
adId string

Banner ad ID

(optional)
adSize AdSize

Banner Ad Size, defaults to SMART_BANNER. IT can be: SMART_BANNER, BANNER, MEDIUM_RECTANGLE, FULL_BANNER, LEADERBOARD, SKYSCRAPER, or CUSTOM

(optional)
width number

Banner width, valid when adSize is set to CUSTOM

(optional)
height number

Banner height, valid when adSize is set to CUSTOM

(optional)
overlap boolean

Allow banner to overlap webview, or else it will push webview up or down to avoid overlap. Defaults to false.

(optional)
position number

Position of banner ad. Defaults to TOP_CENTER. You can use the AdMobPro.AD_POSITION property to select other values.

(optional)
x number

X in pixels. Valid when position is set to POS_XY

(optional)
y number

Y in pixels. Valid when position is set to POS_XY

(optional)
isTesting boolean

Set to true to receive test ad for testing purposes

(optional)
autoShow boolean

Auto show interstitial ad when loaded. Set to false if hope to control the show timing with prepareInterstitial/showInterstitial

(optional)
orientationRenew boolean

Re-create the banner on web view orientation change (not screen orientation), or else just move the banner. Default:true.

(optional)
adExtras AdExtras

Set extra color style for Ad

(optional)
license any

License key for the plugin

(optional)

AdExtras

Param Type Details
color_bg string
color_bg_top string
color_border string
color_link string
color_text string
color_url string

API

Native

General