So I got my game working for both Android, and Iphone, but the only difference is that ads will show up on my android phone, but NOT the iPhone. I added in extra if-statements to see where it’s going wrong.
local function adListener(event) if (event.phase == "init") then showAd() elseif ( event.phase == "request" ) then local adText = display.newText("An Add Was Requested", 30, 30, "Impact", 40) elseif ( event.phase == "found" ) then local adText1 = display.newText("An ad was found", 30, 40, "Impact", 40) elseif ( event.phase == "shown" ) then local adText2 = display.newText("The ad has shown", 30, 50, "Impact", 40) elseif ( event.phase == "closed" or event.phase == "failed" ) then local adText3 = display.newText("An ad was closed/hidden, or an ad could not be found", 30, 60, "Impact", 40) end end
For the iPhone, it’s hitting the failed phase every time.
Here’s some code to see it initialized and blah blah.
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", }, }, excludeFiles = { -- Include only the necessary icon files on each platform android = { "Icon-\*dpi.png", }, iphone = { "Icon.png", "Icon-Small-\*.png", "Icon\*@2x.png", }, }, -- -- iOS Section -- iphone = { plist = { NSAppTransportSecurity = { NSAllowsArbitraryLoads=true }, NSLocationAlwaysUsageDescription = { "" }, NSLocationWhenInUseUsageDescription = { "" }, UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend --ads for iphone 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 = { usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE" }, }, -- -- For Ads -- plugins = { ["plugin.coronaAds"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone=true, android=true } }, ["plugin.google.play.services"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, ["shared.android.support.v4"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, ["plugin.gameanalytics\_v2"] = { publisherId = "com.gameanalytics", supportedPlatforms = { iphone=true, android=true } }, -- ["plugin.googleAnalytics"] = -- { -- publisherId = "com.coronalabs", -- supportedPlatforms = { iphone=true, android=false } -- }, }, }
now in my restart.lua, where the ads are supposed to show:
local coronaAds = require( "plugin.coronaAds" ) local scene = composer.newScene() \_W = display.contentWidth; \_H = display.contentHeight local bannerPlacement = "top-banner-320x50" local interstitialPlacement = "interstitial-1" local randomAd = math.random(1,10)
local function showAd() if randomAd == 10 then coronaAds.hide() coronaAds.show(interstitialPlacement, true) elseif randomAd == 5 or randomAd == 6 or randomAd == 7 or randomAd == 8 or randomAd == 9 then coronaAds.hide() coronaAds.show(bannerPlacement, false) print("entered ad phase 5-9") end end
coronaAds.init("9b883af3-c5b3-41ab-8507-027207b740e8", adListener)
And again, always a thank you for those who take the time to help me out.