Present Apple iAd in Mobile App/Games natively from JavaScript.
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.
}
Cordova/PhoneGap plugins for the world leading Mobile Ad services:
- AdMob Plugin Pro, enhanced Google AdMob plugin, easy API and more features.
- mMedia Plugin Pro, enhanced mMedia plugin, support impressive video Ad.
- iAd Plugin, Apple iAd service.
- FlurryAds Plugin, Yahoo Flurry Ads service.
- MoPub Plugin Pro, MobPub Ads service.
- MobFox Plugin Pro, enhanced MobFox plugin, support video Ad and many other Ad network with server-side integration.
More Cordova/PhoneGap plugins by Raymond Xie, click here.
Project outsourcing and consulting service is also available. Please contact us if you have the business needs.