Both. But that’s not what I meant. My app won’t even display video/reward ads. There’s no error or crash, it just doesn’t show.
Add this to the event listener at the top:
local function adListener(event) -- you already have this line. local json = require( "json" ) -- add this line print(json.prettify(event)) --add this line
build and deploy to the device and then look and see what the logs say.
Im posting this code to see if it will help.
[lua]local function adListener( event )
if ( event.phase == “init” ) then – Successful initialization
print( event.provider )
– Load an StartApp ad
startapp.load( “interstitial” )
startapp.load( “video” )
elseif ( event.phase == “loaded” ) then – The ad was successfully loaded
print( event.type )
elseif ( event.phase == “failed” ) then – The ad failed to load
print( event.type )
print( event.isError )
print( event.response )
elseif ( event.phase == “displayed” ) then – The ad was displayed/played
print( event.type )
elseif ( event.phase == “hidden” ) then – The ad was closed/hidden
print( event.type )
elseif ( event.phase == “clicked” ) then – The ad was clicked/tapped
print( event.type )
elseif ( event.phase == “reward” ) then – Rewarded video ad playback completed
user.money = user.money + 50
loadsave.saveTable(user, “user.json”)
moneyText.text = user.money
startapp.load(“rewardVideo”)
print( “reward” )
print( event.type )
end
end
– Initialize the StartApp plugin
startapp.init( adListener, { appId="", enableReturnAds = true } )[/lua]
My main.lua updated /\
[lua]local function gotoMenu(event)
if(event.phase == “ended”) then
audio.play(clickSnd, {channel = 2})
physics.stop( )
display.remove(newFlag)
display.remove(newSpear)
display.remove(newCoin)
for i = #objTable, 1, -1 do
table.remove( objTable, i)
break
end
for i = #coinTable, 1, -1 do
table.remove( coinTable, i )
break
end
composer.removeScene(“game”)
composer.gotoScene(“menu”)
–show ad
–if ( startapp.isLoaded( “interstitial” ) ) then
startapp.show(“video”)
–end
end
end[/lua]
Trying to display a video ad, when going back to the menu screen. From my game.lua /\
[lua]local function playAd(event)
if (event.phase == “ended”) then
print( “button works” )
if startapp.isLoaded( “rewardedVideo” ) then
startapp.show(“rewardedVideo”)
end
end
end
startapp.load( “rewardedVideo” )[/lua]
This is my function to show my video reward ad. I have a button that calls it. This is from my shop.lua /\
ok
Umm…how do I check the log?
As mentioned before this should be “interstitial” and not “video”:
--show ad --if ( startapp.isLoaded( "interstitial" ) ) then startapp.show("video") --end end
Second you never load a rearded so you need to add rewarded:
if ( event.phase == "init" ) then -- Successful initialization print( event.provider ) -- Load an StartApp ad startapp.load( "interstitial" ) startapp.load( "video" ) startapp.load( "rewardedVideo" ) -- Add this line!
I commented out that if statement because I wanted to try a video ad there without the startapp.isLoaded, I know it’s interstitial not video. Also I loaded the reward video elsewhere in my code, But I can’t remember if I tried loading it in the adListener function, I’ll try that. Though like I said before I think it might be the oldness of my device. But I’ll keep trying to change my code around to see if I can get it to work.
You might be 100% correct and it is the old device that you are using. Where are you located? I can send you a device with a newer OS.
Ha! That might be a bit difficult, since I live in China. My friend’s got a kindle I could borrow, I want to try it on that. Though I’m not sure it will work, since I’m not sure if startapp supports amazon. But I still need to test my app on a newer device.
You can put it up on open beta and I can download it and see what happens. Not sure it is going to work on a Kindle. My guess is no.
That’s what I thought about the kindle. But that beta idea is a good one. But I don’t need to do that. I’ve got mine on mediafire. If you want I could just send the link
Sure send me a link. I’ll try it out on my device.
https://www.mediafire.com/file/0vfffac2lanhiff/Ninja_Wall_Dash.apk/file
The video ads should pop up when your press the home button(the pause screen one and the end game one) while in game.
For the reward video, its in the shop. It’s the home button in the bottom-right (I haven’t made a custom button for it yet).
Thanks
I retested this morning and clicked on the right home button. No reward ads. Are you sure you are calling:
startapp.load( "rewardedVideo" )
I checked the logs and all I see is this:
Just checked, I was using [lua] startapp.load("rewardVideo) [/lua] My bad.
Here’s the link to the fixed build: http://www.mediafire.com/file/rh4swgqhle6mqq9/Ninja_Wall_Dash.apk/file
Also I moved the reward ad button to the buy screen, and I gave it it’s own button.
Works perfectly. Here are the event signatures when completed:
Yay, thanks