Unable to use Cocoon-Admob plugin, ads not showing

Hello. I am trying to use Cocoon-plugin-Ads-android-admob on a game, the ads are not showing. I am not sure if my Ads script is correct. I am using Cocoon 2.2.0, canvas+ webview engine. So if someone could help, I would be very grateful. I tested on an Android device version 4.1.2. Here is my script:

function updateGamePlay() { //This function is updated on every second and is where the game play takes place and where I allow banners to be shown. At the end of this function I make a call to a function named manageBanner()

// The Ads Sections

function initAds() {
appId: “ca-app-pub-----------------------------------------”,
banner: “ca-app-pub-3940256099942544/6300978111”,
interstitial: “ca-app-pub-3940256099942544/1033173712”,
rewardedVideo: “ca-app-pub-3940256099942544/5224354917”,
personalizedAdsConsent: false,

function manageBanner() {
var banner = Cocoon.Ad.Admob.createBanner(“SMART”);
banner.on(“load”, function() {
if(isAdShown == false) {
if(gameStatus == ‘play’) {
banner.on(“show”, function() {
isAdShown = true;
if(gameStatus == ‘menu’ || gameStatus == ‘bonus_prize’) {
isAdShown = false;
function onDeviceReady() {
document.removeEventListener(‘deviceready’, onDeviceReady, false);
document.addEventListener(“deviceready”, onDeviceReady, false);

Kind regards,

Luis Filipe

I think it’s an update issue on the plugin programmers’ side. Just posted a similar complaint to Ludei just now: https://github.com/ludei/atomic-plugins-ads/issues/16

Hello Omar. Thanks for the reply. But I still doubt that my script is correct. Is it just this simple to show a banner? Don’t we need to declare the canvas layer where we want to draw the banners? Can I declare var banner = Cocoon.Ad.Admob.createBanner(“SMART”); every second without causing a reset?

Kind regards,

It seems correct, but why attempting to remove the function “onDeviceReady()” with “document.removeEventListener”?

Also make sure to write your variables before declaring values for them under a function, or else the variable will be exclusive to that function. For example:

var banner;

function manageBanner(){
     banner = Cocoon.Ad.Admob.createBanner(“SMART”);

Also, I noticed that “manageBanner()” isn’t called yet in your example, and it should only be called once to create your ad banner… maybe preferably under the “initAds()” function. Whenever you need the banner to show, declare “banner.show()” at a separate instance within your app long after “$(document).ready()” or even “onDeviceReady()” is initiated.

Hello Omar. Thanks for the reply. I will change the script, try your suggestion and let you know about the outcome.

Kind regards,

Luis Filipe

You can use the following if you’re still having problems:

The AdMob plugins had been having problems lately, but I have a solution that can work on the latest Cocoon version, but it involves using a different AdMob plugin within your Config.xml: <plugin name=“admob” spec="*"/>.

Then, add the following within the “deviceready” event:

admob.initAdmob(bannerAdUnitVar, interstitialAdUnitVar);

//show in ad receive event fun need add receive listener:
document.addEventListener(admob.Event.onInterstitialReceive, onInterstitialReceive, false);
document.addEventListener(admob.Event.onAdmobBannerDismiss, onAdmobEvent, false);
document.addEventListener(admob.Event.onAdmobBannerFailedReceive, onAdmobEvent, false);
document.addEventListener(admob.Event.onAdmobBannerLeaveApplication, onAdmobEvent, false);
document.addEventListener(admob.Event.onAdmobBannerPresent, onAdmobEvent, false);
document.addEventListener(admob.Event.onAdmobBannerReceive, onAdmobEvent, false);
document.addEventListener(admob.Event.onAdmobInterstitialDismiss, function(){
	//You can add any function here.
}, false);
document.addEventListener(admob.Event.onAdmobInterstitialFailedReceive, function(){
	//You can add any function here.
}, false);
document.addEventListener(admob.Event.onAdmobInterstitialLeaveApplication, onAdmobEvent, false);
document.addEventListener(admob.Event.onAdmobInterstitialPresent, function(){
	//You can add any function here.
}, false);
document.addEventListener(admob.Event.onAdmobInterstitialReceive, onAdmobEvent, false);

Now, to preload your ads, call “admob.cacheInterstitial();” for Interstitial Ads, then “admob.showInterstitial();” to launch it.

Hope this helps, while we hope Ludei and even CranBerry will ever fix their own AdMob plugins.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.