DoubleClick for Publishers Cordova Plugin for Android and iOS compatible Phonegap 3.0 CLI
How to install plugin:
cordova plugin add https://github.com/Rickgbw/cordova-plugin-dfp
##Implementation:
There are two calls needed to get DFP Ads:
-
createBannerView
Takes in a object containing a publisherId and adSize, as well as success and failure callbacks. An example call is provided below:
admob.createBannerView( { 'publisherId': 'INSERT_YOUR_PUBLISHER_ID_HERE', 'adSize': admob.AD_SIZE.BANNER }, successCallback, failureCallback );
-
requestAd
Takes in an object containing an optional testing flag, and an optional list of extras. This method should only be invoked once createBannerView has invoked successCallback. An example call is provided below:
admob.requestAd( { 'isTesting': false, 'extras': { 'color_bg': 'AAAAFF', 'color_bg_top': 'FFFFFF', 'color_border': 'FFFFFF', 'color_link': '000080', 'color_text': '808080', 'color_url': '008000' }, }, successCallback, failureCallback );
This plugin also allows you the option to listen for ad events. The following events are supported:
document.addEventListener('onReceiveAd', callback);
document.addEventListener('onFailedToReceiveAd', callback);
document.addEventListener('onDismissScreen', callback);
document.addEventListener('onPresentScreen', callback);
document.addEventListener('onLeaveApplication', callback);
If you want to create an Interstitials sur createInterstitialView
admob.createInterstitialView(
{
'publisherId': 'INSERT_YOUR_PUBLISHER_ID_HERE'
},
successCallback,
failureCallback);
If you want Kill banner :
admob.killAd(successCallback,failureCallback);