Skip to content

RoachHaus/cordova-plugin-iad

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cordova-plugin-iad


This is the Cordova Plugin to support Apple iAd on iOS. It provides a way to request ads natively from JavaScript.

See Also


Besides using Apple iAd, you have some other options, all working on cordova:

How to use

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
...

Weak Linking the iAd Framework

  1. In your project, under "Targets", double click on the Target item
  2. Go to the "General" Tab, under "Linked Libraries"
  3. For the iAd Framework, change the value from "Required" to "Weak"

How to use it in javascript

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.
}

Donate


You can use this cordova plugin for free.

To support this project, donation is welcome.

Donation can be accepted via Paypal:

About

Cordova plugin to support iAd on iOS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published