0

(function() {
  ready("#showAdDiaria", function(element) {

    var el = document.getElementById("showAdDiaria");
    var adunit;
    var userAgent = navigator.userAgent;

    if (/(android)/i.test(userAgent)) {
        // put android ad unit ID here
        adunit = 'ca-app-pub-xxx/xxxx'
    }

    if (/(iPad|iPhone|iPod)/.test(userAgent) ) {
        // put iOS ad unit id here
        adunit = 'ca-app-pub-xx/xx'
    }
    if (AdMob) {
      AdMob.prepareInterstitial({
        adId: adunit,
        isTesting: false,
        autoShow: false
      });
    }

    el.addEventListener("click", function() {
        console.log('clicked show ad', AdMob);
      // show the interstitial later, e.g. at end of game level
      if (AdMob) AdMob.showInterstitial();
    });

  });

})();

when I enter the script I get the error that the Admob variable is not defined

  • please correctly format your code and add some context to what you did (hint: highlight all your code and do `ctrl+k`) – Kevin Hernandez Nov 27 '19 at 15:19
  • I get this error when entering my admobfree script polyfills.js?version=38.1:3 Uncaught ReferenceError: AdMob is not defined at HTMLElement. (custom-38.1.js:24) at MutationObserver.check (mutation-observer.js:41) at t.invoke (polyfills.js?version=38.1:3) at r.runGuarded (polyfills.js?version=38.1:3) at MutationObserver. (polyfills.js?version=38.1:3) – Anderson Azabache Nov 27 '19 at 20:44

0 Answers0