Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Startapp questions
Started by ec0 Jul 06 2018 08:17 PM

29 replies to this topic
[TOPIC CONTROLS]
Page 1 of 2 1 2
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

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

  

 



[TOPIC: post.html]
#2

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

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



[TOPIC: post.html]
#3

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 786 posts
  • Corona SDK

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.



[TOPIC: post.html]
#4

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

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 



[TOPIC: post.html]
#5

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

 

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 /\



[TOPIC: post.html]
#6

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 786 posts
  • Corona SDK

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.



[TOPIC: post.html]
#7

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

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?

[TOPIC: post.html]
#8

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 786 posts
  • Corona SDK

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.



[TOPIC: post.html]
#9

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

Ooooh, ok. Thanks.

[TOPIC: post.html]
#10

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

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

[TOPIC: post.html]
#11

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 786 posts
  • Corona SDK

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.


[TOPIC: post.html]
#12

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

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.

[TOPIC: post.html]
#13

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 786 posts
  • Corona SDK

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.



[TOPIC: post.html]
#14

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

Im posting this code to see if it will help.

 

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

 

My main.lua updated /\

 

 

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

 

Trying to display a video ad, when going back to the menu screen. From my game.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" )

 

This is my function to show my video reward ad. I have a button that calls it. This is from my shop.lua /\



[TOPIC: post.html]
#15

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

ok



[TOPIC: post.html]
#16

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

Umm...how do I check the log?



[TOPIC: post.html]
#17

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 786 posts
  • Corona SDK

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!


[TOPIC: post.html]
#18

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

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.

[TOPIC: post.html]
#19

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 786 posts
  • Corona SDK

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.



[TOPIC: post.html]
#20

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

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.

[TOPIC: post.html]
#21

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 786 posts
  • Corona SDK

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.



[TOPIC: post.html]
#22

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

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

[TOPIC: post.html]
#23

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 786 posts
  • Corona SDK

Sure send me a link. I'll try it out on my device.



[TOPIC: post.html]
#24

ec0

[GLOBAL: userInfoPane.html]
ec0
  • Enthusiast

  • 30 posts
  • Corona SDK

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



[TOPIC: post.html]
#25

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 786 posts
  • Corona SDK

works fine:

 

https://youtu.be/A_DmXfMxzLg




[topic_controls]
Page 1 of 2 1 2
 
[/topic_controls]