2017-05-09 53 views
0

我很有智慧。我無法讓這個插件工作。我跟着這封信的指示,在PhoneGap Cordova Admob plugin not working(當你向下滾動到引用這個插件的答案。)我使用最新的phonegap cli與phonegap服務運行。我甚至創建了一個空白頁面(debug.html)以確保沒有其他代碼受到干擾。Phonegap cordova-plugin-admob-simple無法獲取任何廣告以顯示

我迄今所做的:

  • 確信在主config.xml中
  • 經過在網絡broswer該Admob.js文件實際上是從plugins文件夾加載存在的插件。
  • 確信該插件在平臺/ Android的引用/ android.json
  • 確保我的鏈接頁面
  • 確信插件是位於平臺/安卓/資產/ WWW上cordova.js /插件
  • 平臺Android的加入
  • 該插件在PhoneGap的插件列表中顯示
  • 沒有錯誤安裝插件時和/或當我運行的PhoneGap服務
  • 試圖與isTesting真假兩
  • 確保deviceready實際上正在觸發
  • 檢查並重新檢查了我的Admob代碼。

我總是得到'admob插件沒有準備好'的提醒。

我試着將行「window.plugins.AdMob」更改爲AdMob,plugins.Admob,navigator.Admob,window.Admob。我仍然得到這個錯誤。

當我註釋掉該檢查(「if(window.plugins & & window.plugins.AdMob){」),並強制它運行代碼時,沒有任何反應。我在命令行上沒有發現錯誤,在任何可以找到調試的地方都沒有錯誤。

這裏是我的代碼:

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8" /> 
    <meta name="format-detection" content="telephone=no" /> 
    <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 --> 
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> 
    <meta name="msapplication-tap-highlight" content="no" /> 
    <title>Debug Page</title> 
    <style> 
     .bodyStyle{ 
      font-size: 32px; 
     } 
    </style> 
    <script type="text/javascript" charset="utf-8" src="cordova.js"></script> 

</head> 
<body > 
<script> 
    function onDeviceReady() { 
     console.log("DEVICE READY"); 
//initialize the goodies 

     if (window.plugins && window.plugins.AdMob) { 
      var ad_units = { 
       ios : { 
        banner: 'ca-app-pub-1631005955280974/1599263468',  //PUT ADMOB ADCODE HERE 
        interstitial: 'ca-app-pub-1631005955280974/6029463060' //PUT ADMOB ADCODE HERE 
       }, 
       android : { 
        banner: 'ca-app-pub-1631005955280974/1599263468',  //PUT ADMOB ADCODE HERE 
        interstitial: 'ca-app-pub-1631005955280974/6029463060' //PUT ADMOB ADCODE HERE 
       } 
      }; 
      var admobid = (/(android)/i.test(navigator.userAgent)) ? ad_units.android : ad_units.ios; 

      window.plugins.AdMob.setOptions({ 
       publisherId: admobid.banner, 
       interstitialAdId: admobid.interstitial, 
       adSize: window.plugins.AdMob.AD_SIZE.SMART_BANNER, //use SMART_BANNER, BANNER, IAB_MRECT, IAB_BANNER, IAB_LEADERBOARD 
       bannerAtTop: false, // set to true, to put banner at top 
       overlap: true, // banner will overlap webview 
       offsetTopBar: false, // set to true to avoid ios7 status bar overlap 
       isTesting: true, // receiving test ad 
       autoShow: true // auto show interstitial ad when loaded 
      }); 

      registerAdEvents(); 
      window.plugins.AdMob.createInterstitialView(); //get the interstitials ready to be shown 
      window.plugins.AdMob.requestInterstitialAd(); 

     } else { 
      alert('admob plugin not ready'); 
     } 

//functions to allow you to know when ads are shown, etc. 
function registerAdEvents() { 
     document.addEventListener('onReceiveAd', function(){}); 
     document.addEventListener('onFailedToReceiveAd', function(data){}); 
     document.addEventListener('onPresentAd', function(){}); 
     document.addEventListener('onDismissAd', function(){ }); 
     document.addEventListener('onLeaveToAd', function(){ }); 
     document.addEventListener('onReceiveInterstitialAd', function(){ }); 
     document.addEventListener('onPresentInterstitialAd', function(){ }); 
     document.addEventListener('onDismissInterstitialAd', function(){ 
      window.plugins.AdMob.createInterstitialView();   //REMOVE THESE 2 LINES IF USING AUTOSHOW 
      window.plugins.AdMob.requestInterstitialAd();   //get the next one ready only after the current one is closed 
     }); 
    } 
    function showBannerFunc(){ 
    AdMob.createBannerView(); 
} 
//display the interstitial 
function showInterstitialFunc(){ 
    AdMob.showInterstitialAd(); 
} 

    document.addEventListener("deviceready", onDeviceReady, false); 
</script> 
<button type='button' onclick='showBannerFunc();'>SHOW BANNER</button> 
<br/><br/> 
<button type='button' onclick='showInterstitialFunc();'>SHOW INTER</button> 
</body> 
</html> 

這是主要的config.xml爲

<plugin name="cordova-plugin-admob-simple" spec="~3.3.3" /> 

拜託,我已經在這個超過2周,我用Google搜索和搜索所有我可以。我必須閱讀至少100頁尋求幫助,不知道還有什麼要嘗試。我發現的一切,我都試圖無濟於事。即使發生了什麼不同,它只是不顯示任何形式的廣告。橫幅或其他。即使我點擊按鈕。請幫幫我。謝謝。

回答

0

好吧,我終於明白了。我使用的是Phonegap Serve。這不支持插件,或至少第三方插件。你必須使用Phonegap運行。

0

我現在正處於2周前的階段。我已經測試過AdMob的不同插件,但沒有顯示任何廣告。 不幸的是,即使我生成一個apk文件並在移動設備上運行它,也沒有任何反應。 我已經使用過您的代碼,但按下「顯示橫幅」按鈕時沒有顯示任何內容。

我已經使用了虛擬ID(ca-app-pub-3940256099942544/6300978111)以及我自己的ID。

也許你可以看看我的問題,並給出建議: Using AdMob and Cordova - ad is not displayed

感謝,

彼得

相關問題