iAd

Apple iAd support (iOS only) to your cordova apps or games to earn more revenue
Liming Xie0.1.836
platforms: ios
$ cordova plugin add com.rjfun.cordova.plugin.iad

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.