Skip to content

andrey-abstracted/cordova-plugin-iad

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cordova-plugin-iad


Present Apple iAd in Mobile App/Games natively from JavaScript.

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

See Also

Cordova/PhoneGap plugins for the world leading Mobile Ad services:

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.

About

Cordova plugin to support iAd on iOS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 90.9%
  • JavaScript 9.1%