Phonegap display plaque advertising tutorial
The preparation for coding
Before reading this tutorial, please read the getting started with cordova tutorial to learn how to download management library, how to install AD management library
Add advertising related Js code
1. Initialization Keymob
Initialization Keymob library management is the prerequisite to call other advertising functions, the following initialization method is to use the Keymob.com service
keymob.initFromKeymobService("1", true);
Parameter Description
- "1" the first parameter is the ID Keymob application, at Keymob.com for creating an application
ID
- "true" "false" Whether testing mode, set to true when debug, set false when released
2.loading ads
keymob.loadInterstitial();
3.Check whether advertising plaque load successfully
keymob.isInterstitialReady(function (isReady) {
if (isReady) {
alert("Interstitial is load success,you can show it now");
}
});
4.display ads
keymob.showInterstitial();
5. Show Interstitial
Check whether ad is load successfully is a good practice
keymob.isInterstitialReady(function (isReady) {
if (isReady) {
keymob.showInterstitial();
}
});
6.Monitor advertising events
In Interstitial advertising can show at the end of the game or show it manual ,or can be shown when loaded
function onAdReceive(message) {
if(message.adtype==keymob.AdTypes.INTERSTITIAL){
alert(message.adtype + message.adapter+" ,you can show it now");
}
//keymob.showInterstitial();//show it when received
}
document.addEventListener(keymob.AdEvent.ON_LOADED_SUCCESS, onAdReceive, false);
Processing for each platform
After add the code, in accordance with the previous tutorial, processing for android and ios
More tutorial of add ad in app qq group 310513042 home