floatinghotpot / cordova-plugin-chartboost

Cordova plugin for Chartboost Ads
MIT License
2 stars 0 forks source link

Cordova plugin for Chartboost

Show Mobile Ad with single line of javascript code

Step 1: Create Ad Unit Id for your game, then write it in your javascript code.

// select the right Ad Id according to platform
    var adunits = {};
    if( /(android)/i.test(navigator.userAgent) ) { 
        adunits = { // for Android
            appId: '543f9b02c26ee436f622d806',
            appKey: '5091e071a0e429129ea7dc5b69fe005296de40ef'
        };
    } else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) {
        adunits = { // for iOS
            appId: '543f9ac9c26ee436e7133794',
            appKey: '6d1c2e4a5d1225825a7472aa52d0f45e4757de39'
        };
    } else {
        alert('windows phone not supported');
    }

    function initApp() {
        if (! Chartboost ) { alert( 'Chartboost plugin not ready' ); return; }

        Chartboost.setOptions( {
                 appId: adunits.appId,
                 appKey: adunits.appKey
        } );

        registerAdEvents();
    }

Step 2: Want interstitial Ad? single line of javascript code.

if(Chartboost) Chartboost.prepareInterstitial( {
    adId: 'interstitial/Home Screen', 
    autoShow: true } );

Step 3: Want show video? Easy, single line of code.

if(Chartboost) Chartboost.prepareInterstitial( {
    adId: 'video/Home Screen', 
    autoShow: true } );

Step 4: Want show more apps? Easy, single line of code.

if(Chartboost) Chartboost.prepareInterstitial( {
    adId: 'moreapps/Home Screen', 
    autoShow: true } );

Features

Platforms supported:

Highlights:

How to use?

Quick start with cordova CLI

    # create a demo project
    cordova create test1 com.rjfun.test1 Test1
    cd test1
    cordova platform add android
    cordova platform add ios

    # now add the plugin, cordova CLI will handle dependency automatically
    cordova plugin add cordova-plugin-chartboost

    # now remove the default www content, copy the demo html file to www
    rm -r www/*;
    cp plugins/cordova-plugin-chartboost/test/* www/;

    # now build and run the demo in your device or emulator
    cordova prepare; 
    cordova run android; 
    cordova run ios;
    # or import into Xcode / eclipse

Javascript API Overview

Methods:

// set default value for other methods
setOptions(options, success, fail);

// use interstitial
prepareInterstitial(adId/options, success, fail);
showInterstitial();

Screenshots

See Also

Ad PluginPro series for the world leading Mobile Ad services:

More Cordova/PhoneGap plugins by Raymond Xie, find them in plugin registry.

If use in commercial project and need email/skype support, please buy a license, you will be supported with high priority.

Project outsourcing and consulting service is also available. Please contact us if you have the business needs.