Startapp questions

So I’ve gotten the startapp plugin to work. I can load interstitial and banner ads, but when I try to load a video ad, nothing happens. (I’m testing on an android device that runs 4.0.4)

Also can I run different types of ads in one game (video, reward, interstitial, etc)? If so how would I do that?

I followed the documentation, and that’s what I’m using in my code. 

My game uses the composer library. So what would be the best way to layout the startapp ad code to work on the different composer scenes? 

Any other tips and suggestions on using the startapp plugin would be great

  

Also how do I use reward videos? And how do I use it so it will work with interstitial and video ads?

Wow those are a lot of questions and you have to give people time to response before nudging especially at the time of your question and your nudge.

But anyway:.

  1. Search for the forums, I believe @romaminggamer has some information on how to appropriately deal with ads.

  2. Do you have a newer device you can test with? 4.0.4 is very old, I would look for something with at least 4.3

  3. Post your code and the logs so we can have a better idea of what is going wrong.

Nudge?

And ok, I’ll check him out.

And no. That’s pretty much the only android device I have. 

Also I will post my code here if that will help.

Sorry about the time of my posting, it was day here. Though I am aware of the different time zones.

Thanks 

centerX = display.contentCenterX

centerY = display.contentCenterY

_W = display.contentWidth

_H = display.contentHeight

local composer = require( “composer” )

loadsave = require(“lib.loadsave”)

magnet = require ( “lib.magnet” ) 

startapp = require( “plugin.startapp” )

local function adListener( event )

    if ( event.phase == “init” ) then  – Successful initialization

        print( event.provider )

        – Load an StartApp ad

        startapp.load( “interstitial” )

        --tartapp.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

        print( event.type )

    end

end

– Initialize the StartApp plugin

startapp.init( adListener, { appId="", enableReturnAds = true } )

– Hide status bar

display.setStatusBar( display.HiddenStatusBar )

– Seed the random number generator

math.randomseed( os.time() )

–audio.reserveChannels( 1 )

–audio.setVolume( 0.1, { channel=1 } )

coinSnd = audio.loadSound(“sounds/moneyPickup.wav”)

cashRegSnd = audio.loadSound(“sounds/cashRegister.wav”)

jumpSnd = audio.loadSound(“sounds/whoosh.wav”)

clickSnd = audio.loadSound(“sounds/buttonClick.wav”)

hurtSnd = audio.loadSound(“sounds/hurt.wav”)

–bgMusic = audio.loadStream(“sounds/ninjaWall.wav”)

audio.setVolume( 0.9, {channel = 2} )

audio.setVolume( 1, {channel = 3} )

–setup save file for user

user = loadsave.loadTable(“user.json”)

–user = nil

if(user == nil) then

user = {}

user.money = 0

user.highscore = 0

user.playsound = true

user.skin = “ninja”

user.whiteNinja = false

user.girlNinja = false

user.lizardMan = false

user.robot = false

user.worker = false

user.chef = false

loadsave.saveTable(user, “user.json”)

end

– Go to the menu screen

composer.gotoScene( “menu” )

my main.lua /\

startapp.show(“interstitial”)

This is how I show my ad /\

  1. To load rewarded you need to do the same as you are doing with interstitial. You can put it right under the request to load the interstitial, but it is usually better to load it closer to the event where the user will have an opportunity for a reward.

    startapp.load( “rewardedVideo” )

  2. Then where you want to show it, check to see if it is loaded and show your reward dialog (basically asking the user if they want to watch a video for a reward of xxxx).

    if startapp.isLoaded( “rewardedVideo” ) then – Show your reward dialog. end

  3. If the user says yes then show it:

    startapp.show( “rewardedVideo” )

  4. Once you get the event.phase = reward call back give the user what you offered for a reward:

    elseif ( event.phase == “reward” ) then – Rewarded video ad playback completed --give user reward end

  5. Remember to load the next reward ad when appropriate or when the last ad is closed.

Hopefully, this response helps you a little.

Ok, thanks. This will help. I’ll give it a try. Just one question. After I show the ad, do I call the adListener function for the “elseif (event.phase == “reward”), or do I write a new if statement?

You already have the “reward” statement. You don’t need to write another one. When they finish viewing the video it will just land there so that you can give them the reward.

Ooooh, ok. Thanks.

Do startapp video based ads not work on older devices? Because while interstitial ads work just fine the video based ads don’t show.

Rewarded videos or plain interstitial video ads? At least in my experience, the native sdk and the corona sdk does not currently support calling non-rewarded video ads directly. When you ask for an interstitial you will get a mix of static and video ads. I think the documentation should be updated to remove the reference to video ads.

From their documentation about interstitial:

When integrating this ad type you are open to get both Display or Video ads. Our optimization will auto-select the ad type that will generate the most revenue for you.

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.