This is the Cordova Plugin to support Apple iAd on iOS. It provides a way to request ads natively from JavaScript.
Besides using Apple iAd, you have some other options, all working on cordova:
- cordova-plugin-flurry, Flurry Ad service.
- cordova-plugin-admob, Google AdMob service.
Use Cordova/Phonegap command line tool:
cordova create testiad com.rjfun.testiAd testiAd
cd testiad
cordova platform add ios
cordova plugin add https://github.com/floatinghotpot/cordova-plugin-iad.git
...
- In your project, under "Targets", double click on the Target item
- Go to the "General" Tab, under "Linked Libraries"
- For the iAd Framework, change the value from "Required" to "Weak"
document.addEventListener("deviceready", onDeviceReady, false);
document.addEventListener("onClickAd", onClickAd, false);
document.addEventListener("onReceiveAd", onReceiveAd, false);
document.addEventListener("onFailedToReceiveAd", onFailedToReceiveAd, false);
function onDeviceReady() {
if ( window.plugins && window.plugins.iAd ) {
window.plugins.iAd.createBannerView(
{
'bannerAtTop': false,
'overlap': false,
'offsetTopBar' : false
}, function() {
window.plugins.iAd.showAd( true );
}, function(){
alert( "failed to create ad view" );
});
} else {
alert('iAd plugin not available/ready.');
}
}
function onClickAd() {
// count click
}
function onReceiveAd() {
// do whatever you want
}
function onFailedToReceiveAd( ret ) {
// alert( ret.error );
// no need to handle it, sometimes ad just not loaded in time, but iad will try reload,
// once it's loaded, it will be displayed.
}
You can use this cordova plugin for free.
To support this project, donation is welcome.
Donation can be accepted via Paypal: