2014-03-29 30 views
3

如何在Android手机差距应用中集成InMobi广告。我找不到任何关于它的事情。 InMobi有没有android插件?有没有人已经实施InMobi Android手机差距应用程序?我想这个代码,但是这是不工作如何在android phonegap应用中集成inmobi广告

var userIP = "115.246.164.46"; 
var useragent = "Mozilla/5.0 (Linux; U; Android 4.0.3; ko-kr; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"; 
$.ajax({ 
    url: "http://api.w.inmobi.com/showad/v2", 
    type: 'POST', 
    contentType: "application/json charset=utf-8", 
    data: { 
     "responseformat": "axml", 
     "imp": [{ 
      "ads": 1, 
      "adtype": "int", 
      "banner": { 
       "adsize": 14, 
       "pos": "top", 
       "api": 1 
      } 
     }], 
     "site": { 
      "id": "e702096c879446f39755da0e81b1d5c5" 
     }, 
     "device": { 
      "ip": userIP, 
      "ua": useragent 
     } 
    }, 
    success: function(d) { 
     alert(d); 
    }, 
    error: function(request, status, error) { 
     alert(error); 
    } 
}); 
+0

我从我的InMobi。您正在使用的JS API适用于移动网站等,它不是为phoneGap构建的。话虽如此,你仍然可以在你的phoneGap应用程序中使用它,尽管它对我们来说很难提供相同的支持。 – Sohan

回答

1

你需要inmobi.js和尝试下面的代码:

var inmobi_conf = 
    { 
    siteid : "4028cba631d63df10131e1d3191d00cb", // your Property ID 
    slot: 15, 
    test: true, 
    manual: true, 
    autoRefresh: 60, 
    targetWindow : "_blank", 
    onError : function(code) 
    { 
     if(code == "nfr") 
     { 
     console.log("Error getting the ads!"); 
     } 
    } 
    }; 

    document.addEventListener("deviceready", onDeviceReady, false); 

    function onDeviceReady() 
    { 
    console.log('device ready'); 
    $.getScript("inmobi.js", function(){ 
     showAds(); 
    }); 
    } 

    function showAds() 
    { 
    var adsElement = document.getElementById('the id of the DOM element for displaying the ads'); 
    _inmobi.getNewAd(adsElement); 
    } 
+0

此代码可以在live site上运行。它不适用于phonegap应用程序 –

+1

请参阅此文档(http://docs.monaca.mobi/en/sampleapp/tips/inmobi/)以获取关于如何将inmobi集成到混合应用程序。它基于Monaca,但我认为你对你应该做的事情有足够的了解。 – Tamura

+1

此演示适用于移动网站,不适用于离线,如手机放大器 –

相关问题