Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

AdMob module issues: advs not appear

$
0
0

I'm using Admob module in one of my app already present on Google Play (http://goo.gl/w24sgN), but so far there has never been an impression. If I use the test mode, banner test is properly displayed, but when I switch to the distribution mode, I always get Admob.AD_NOT_RECEIVED. I can not understand what could be the problem. This happens both for the campaign created for the Android app, which for the one created for iOS. This is my code:

///////////// ADS
if(!Alloy.Globals.fullversion){
 
    var myPromoView = Ti.UI.createView({
        backgroundColor : "transparent",
        top : OS_IOS ? "42dp" : "0dp",
        height : "50dp",
        width : "100%",
        visible : false,
        zIndex : 1
    });
    $.eventListWin.add(myPromoView);
    var myAds = require("astrovicAppsAds").selectAds();
    myAds.addEventListener('click', function(){
        Ti.Platform.openURL(myAds.openStore);
        Alloy.Globals.tracker.event("astrovicAppsAds","click","astrovicAppsAds",0);
    });
    myPromoView.add(myAds);
 
    // Randomly (if i get number 2 between 1 and 5), I show my app ads instead of AdMob
    if(Math.floor((Math.random() * 5) + 1) != 2){
        if(Alloy.Globals.debug_mode)
            Ti.API.info("ADMOB!");
        if(OS_IOS){
            var Admob = require('ti.admob');
            /*
             We'll make two ads. This first one doesn't care about where the user is located.
             */
            var adMobView = Admob.createView({
                top: 42,
                width: 320, height: 50,
                adUnitId: Alloy.Globals.adMob.ios, // You can get your own at http: //www.admob.com/
                adBackgroundColor: 'transparent',
                // You can get your device's id for testDevices by looking in the console log after the app launched
                //testDevices: [Admob.SIMULATOR_ID],
                dateOfBirth: new Date(1985, 10, 1, 12, 1, 1),
                //gender: 'male',
                //keywords: ''
            });
            $.eventListWin.add(adMobView);
 
            var iAdsView = Ti.UI.iOS.createAdView({
                top: 42,
                width: Ti.UI.SIZE, height: 50,
                zIndex : 1              
            });
 
            adMobView.addEventListener('didReceiveAd', function() {
                if(Alloy.Globals.debug_mode)
                    Ti.API.info('Did receive ad!');
                myPromoView.hide();
                myAds.clearInterval();
            });
            adMobView.addEventListener('didFailToReceiveAd', function() {
                if(Alloy.Globals.debug_mode)
                    Ti.API.info('Failed to receive ad!');               
                adMobView.hide();
                $.eventListWin.add(iAdsView);
            });
            iAdsView.addEventListener('load', function() {
                iAdsView.show();
                myAds.clearInterval();
            });
            iAdsView.addEventListener('error', function(e) {
                iAdsView.hide();
                myPromoView.show();
            });
            iAdsView.addEventListener('action', function(e) {
                Alloy.Globals.tracker.event("iAds","click","iAds",1);
                if(Alloy.Globals.debug_mode)
                    Ti.API.info('iAdsView click!'); 
            });         
            /*adMobView.addEventListener('willPresentScreen', function() {
                Ti.API.info('Presenting screen!');
            });
            adMobView.addEventListener('willDismissScreen', function() {
                Ti.API.info('Dismissing screen!');
            });
            adMobView.addEventListener('didDismissScreen', function() {
                Ti.API.info('Dismissed screen!');
            });*/
            adMobView.addEventListener('willLeaveApplication', function() {
                Ti.API.info('Leaving the app!');
                Alloy.Globals.tracker.event("adMob","click","adMob",1);
            }); 
 
        }else{
            var Admob = require('ti.admob');
 
            // then create an adMob view
            var adMobView = Admob.createView({
                publisherId: Alloy.Globals.adMob.android,
                testing: false, // default is false
                top: 0, // optional
                width: 320, height: 50,
                adBackgroundColor:"transparent",
                //testDevices : "59FE7007404217A942F01AC03DDD9F56"
            });
            $.eventListWin.add(adMobView);
 
            //listener for adReceived
            adMobView.addEventListener(Admob.AD_RECEIVED,function(){
               if(Alloy.Globals.debug_mode)
                   Ti.API.info("ad received");
               myPromoView.hide();
            });
 
            //listener for adNotReceived
            adMobView.addEventListener(Admob.AD_NOT_RECEIVED,function(){
                //alert("ad not received");
                 if(Alloy.Globals.debug_mode)
                    Ti.API.info("ad not received");
                 myPromoView.show();
            });
 
        };
    }else{
        if(Alloy.Globals.debug_mode)
            Ti.API.info("astrovicAppsAds!");
        myPromoView.show();
    }
 
    if(!Ti.Network.online){
        myPromoView.show();
    };
};

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>