I implement chartboost ad for android and ios. and my app is live.
There is rewarded and interstitial of chartboost.
IOS running perfect.
but android give me rewarded 2-3 times then after not load ad.and interstitial also not showing me.
Code is perfect because test mode working perfect.
Please help
HERE is my code:
adUnit = {}
local composer = require “composer”
– ads = require “ads”
chartboost = require( “plugin.chartboost” )
adUnit.isHide = true
– textMode = display.newText( “No AD”, display.contentWidth/2, display.contentHeight - 20, native.systemFont , 25 )
– textMode:setFillColor( 0 )
if (sysEnv == “Android”) then
--adUnit.bannerAdId = “ca-app-pub-1801421226985811/9879122284”
adUnit.interstitialAdId = “ca-app-pub-1801421226985811/5460975484”
adUnit.videoAdId_chartboost = “58c0f39943150f6a3bca11d0”–“58c0f39943150f6a3bca11d0”
adUnit.videoAdSign_chartboost = “67bbe6353115c074f1b31db02d13cad619b37a97”–“67bbe6353115c074f1b31db02d13cad619b37a97”
elseif (sysEnv == “iPhone OS”) then
--adUnit.bannerAdId = “ca-app-pub-1801421226985811/5309321886”
adUnit.interstitialAdId = “ca-app-pub-1801421226985811/8414441883”–“ca-app-pub-1801421226985811/8262788287”
adUnit.videoAdId_chartboost = “58be528f04b0167779d81d0c”–“58be528f04b0167779d81d0c”–“58be523b43150f03a7ada295”
adUnit.videoAdSign_chartboost = “ad6bda4c51dcd05d98a9d072f6faf55d0ab26267”–“ad6bda4c51dcd05d98a9d072f6faf55d0ab26267”
end
– adUnit.adProvider = “admob”
adUnit.adListener = function(event)
local msg = event.response
– Quick debug message regarding the response from the library
print( "Message from the ads library: ", msg )
if ( event.isError ) then
print( “Error, no ad received”, msg )
elseif ( event.phase == “loaded” ) then
– an ad was preloaded
elseif ( event.phase == “shown” ) then
– the ad was viewed and closed
– adUnit.adLoad()
end
end
adUnit.adListenerChartboost = function(event)
if ( event.phase == “init” ) then – Successful initialization
--textMode.text = “init”
chartboost.load( “interstitial” , “Game Over” )
chartboost.load( “rewardedVideo” , “Item Store” )
elseif ( event.phase == “loaded” ) then
if (event.type == “rewardedVideo”) then
--textMode.text = “loaded video”
elseif (event.type == “interstitial”) then
--textMode.text = “loaded interstitial”
end
elseif ( event.phase == “displayed” ) then
elseif ( event.phase == “closed” ) then
if (event.type == “interstitial”) then
--textMode.text = “displayed Interstital”
if (chartboost.isLoaded( “interstitial” , “Game Over” )) then
----
else
chartboost.load( “interstitial” , “Game Over” )
end
end
elseif ( event.phase == “reward” ) then
--textMode.text = “reward”
if (_G.rewardClick ~= nil and _G.rewardId ~= nil and _G.rewardClick == “Weapons”) then
composer.storePurchase.weapons[_G.rewardId] = composer.storePurchase.weapons[_G.rewardId] + 1
changeValueOfCoinsAndWeapons(_G.rewardId,“Weapons”)
else
composer.storePurchase.totalCoins = composer.storePurchase.totalCoins + 50
changeValueOfCoinsAndWeapons(1,“Coins”)
end
loadSave.saveTable(composer.storePurchase , “storePurchase.json”)
if (chartboost.isLoaded( “rewardedVideo” , “Item Store” )) then
-----
else
chartboost.load( “rewardedVideo” , “Item Store” )
end
end
end
adUnit.adInit = function()
– ads.init( adUnit.adProvider, adUnit.bannerAdId , adUnit.adListener )
– ads.init( adUnit.adProvider, adUnit.interstitialAdId , adUnit.adListener)
chartboost.init( adUnit.adListenerChartboost, { appId = adUnit.videoAdId_chartboost, appSig = adUnit.videoAdSign_chartboost } )
end
adUnit.adShow = function( name )
if (name == “banner”) then
adUnit.isHide = false
ads.show(“banner”, { x = 0, y = _H - display.screenOriginY, appId = adUnit.bannerAdId } )
elseif (name == “interstitial”) then
if (chartboost.isLoaded( “interstitial” , “Game Over” )) then
chartboost.show( “interstitial” , “Game Over” )
else
chartboost.load( “interstitial” , “Game Over” )
end
elseif (name == “rewardedVideo”) then
if (chartboost.isLoaded( “rewardedVideo” , “Item Store” )) then
chartboost.show( “rewardedVideo” , “Item Store” )
else
local function onComplete( e )
chartboost.load( “rewardedVideo” , “Item Store” )
end
native.showAlert( “title”, “You have to purchase or wait some time for load video.”,{“OK”},onComplete )
end
end
end
adUnit.adLoad = function()
--ads.load( “interstitial”, { appId = adUnit.interstitialAdId } )
end
adUnit.adHide = function()
if (adUnit.isHide == false) then
– ads.hide()
adUnit.isHide = true
end
end
return
--------Build.settings -------
–
– For more information on build.settings see the Corona SDK Build Guide at:
– https://docs.coronalabs.com/guide/distribution/buildSettings
settings =
{
orientation =
{
– Supported values for orientation:
– portrait, portraitUpsideDown, landscapeLeft, landscapeRight
default = “landscapeRight”,
supported = { “landscapeRight”, },
},
plugins =
{
[“CoronaProvider.native.popup.social”] =
{
publisherId = “com.coronalabs”
},
[“plugin.google.iap.v3”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
[“plugin.chartboost”] =
{
publisherId = “com.coronalabs”
},
--[“CoronaProvider.gameNetwork.apple”] =
--{
--publisherId = “com.coronalabs”,
--supportedPlatforms = { iphone=true}
--},
[“plugin.gpgs”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
},
–
– iOS Section
–
iphone =
{
plist =
{
UIStatusBarHidden = false,
UIPrerenderedIcon = true, – set to false for “shine” overlay
--UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend
MinimumOSVersion = “7.0”,
CFBundleIconFiles =
{
“Icon.png”,
“Icon@2x.png”,
“Icon-167.png”,
“Icon-60.png”,
“Icon-60@2x.png”,
“Icon-60@3x.png”,
“Icon-72.png”,
“Icon-72@2x.png”,
“Icon-76.png”,
“Icon-76@2x.png”,
“Icon-Small.png”,
“Icon-Small@2x.png”,
“Icon-Small@3x.png”,
“Icon-Small-40.png”,
“Icon-Small-40@2x.png”,
“Icon-Small-50.png”,
“Icon-Small-50@2x.png”,
},
},
},
–
– Android Section
–
android =
{
googlePlayGamesAppId = “556156679241”,
usesPermissions =
{
“android.permission.INTERNET”,
“android.permission.ACCESS_NETWORK_STATE”,
“com.android.vending.BILLING”,
“android.permission.ACCESS_WIFI_STATE”,
“android.permission.READ_PHONE_STATE”,
“android.permission.WRITE_EXTERNAL_STORAGE”
},
},
}