cordova - 如何在 Android phonegap 应用程序中集成 inmobi 广告

标签 cordova phonegap-plugins inmobi

如何将 InMobi 广告集成到 Android 手机差距应用中。我找不到任何相关信息。 InMobi 有安卓插件吗?是否有人已经实现了 InMobi Android 手机差距应用程序?我试过这段代码,但这不起作用

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);
    }
});

最佳答案

你需要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);
  }

关于cordova - 如何在 Android phonegap 应用程序中集成 inmobi 广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22733015/

相关文章:

Android Phonegap/Webkit/Viewport 位置固定

android - 电话链接android不工作(银河S5)

Cordova插件手动安装

android - Cordova平台添加android报错

android - Cordova/phonegap Activity 生命周期

ios - 不显示 Inmobi 广告

node.js - 安装phonegap时出现错误

javascript - iOS 上的 Phonegap/Cordova + MapKit : Execute javascript function when a pin is tapped

ios - 集成 inmobi 和 Millennial Media SDK