Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

I need help with rewarded video
Started by dodi_games Sep 25 2019 03:44 PM

4 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

dodi_games

[GLOBAL: userInfoPane.html]
dodi_games
  • Contributor

  • 396 posts
  • Corona SDK

I'm a little frustrated because I just published my first game on Google Play and after almost a year of testing with the "test mode = true" of the Appodeal plugin without any error now my code does not detect the "playBackEnded" with the "test mode = false"

 

You know how frustrating it is for my players to see an ad and not receive anything  :( 

 

I really don't know where to start asking the questions so I will try to be brief but I know it will be a long explanation. I will appreciate the patience of those who want to help me.

 

I have a module called ads.lua with several functions.

 

listener & init() & rewarded video function:

-- Ad listener function
M.adsListener = function( event )
  -- Successful initialization of the Appodeal plugin
  if ( event.phase == "init" ) then
        print( "Appodeal event: initialization successful" )
        
  -- An ad loaded successfully
  elseif ( event.phase == "loaded" ) then
        print( "Appodeal event: ad loaded successfully" )
        print( event.type )
  -- The ad was displayed
  elseif ( event.phase == "displayed" ) then
        print( "Appodeal event: ad displayed" )
        print( event.type )
  -- The ad was played
  elseif ( event.phase == "playbackBegan" ) then
        print( "Appodeal event: ad playback Began" )
        print( event.type )
  -- The ad was closed/hidden
  elseif ( event.phase == "hidden" or event.phase == "closed" ) then
        print( "Appodeal event: ad closed/hidden" )
        print( event.type )
  -- The ad was closed/hidden
  elseif ( event.phase == "playbackEnded" ) then
        print( "Appodeal event: ad playback Ended" )
        print( event.type )
    
        loads.numOfLives  = 6
        loads.heartStatus = 0
        loads.updateGameProgress()

  -- The user clicked/tapped an ad
  elseif ( event.phase == "clicked" ) then
        print( "Appodeal event: ad clicked/tapped" )
        print( event.type )
  -- The ad failed to load
  elseif ( event.phase == "failed" ) then
        print( "Appodeal event: ad failed to load" )
        print( event.type )
        print( event.isError )
        print( event.response )
  end
end
-- initialize ad plugin function
M.startAdsPlugin = function( event )
  appodeal.init( M.adsListener, {
    appKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    testMode = false,
    childDirectedTreatment = false,
    disableWriteExternalPermissionCheck = false,
    supportedAdTypes = {"interstitial", "rewardedVideo"},
    hasUserConsent = (gameSettings.userConsent or false),
  
    disableNetworks =
    {
      "amazon_ads",
      "facebook",
      "flurry",
      "my_target",
      "mintegral",
      "ogury",
      "yandex",
      "mopub"
    }
  } )
end
-- show rewarded video ad function
M.showRewardedVideoAd = function( event )
  print( "--Start to show rewarded video ad--" )
  if ( appodeal.isLoaded( "rewardedVideo" ) ) then
    appodeal.show( "rewardedVideo" )
  end
  print( "--Ad shown--" )
end

In the game there is a heart that when filled allows me to refill lives if the player see a rewarded video. I start the Appodeal plugin in the main.lua requiring the ads module and executing the function ads.startAdsPlugin().  When the player has one life left I open an overlay scene with a question if you want to see a

rewarded video to refill lives and continue the game.  Everything works perfectly with the "test mode = true".  the nightmare

began with the "test mode = false".

 

build settings:

 

--
-- For more information on build.settings, see the Project Build Settings guide at:
-- https://docs.coronalabs.com/guide/distribution/buildSettings
--
settings =
{
 orientation =
 {
  -- Supported values for orientation:
  -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight
  default = "portrait",
  supported = { "portrait", },
 },
 --
 -- Android section
 --
 android =
 {
  usesPermissions =
  {
   "android.permission.INTERNET",
   "android.permission.ACCESS_NETWORK_STATE",
   "android.permission.WRITE_EXTERNAL_STORAGE",
   "android.permission.GET_ACCOUNTS",
   "android.permission.ACCESS_COARSE_LOCATION",
   "android.permission.ACCESS_FINE_LOCATION",
  },
  applicationChildElements =
  {
    [[
      <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="xx-xxx-xxx-xxxxxxxxxxxxxxxx~xxxxxxxxxx"/>
    ]],
  },
 },



 --
 -- iOS section
 --
 iphone =
 {
  xcassets = "Images.xcassets",
  plist =
  {
   UIStatusBarHidden = false,
   UILaunchStoryboardName = "LaunchScreen",
   NSAppTransportSecurity = { NSAllowsArbitraryLoads=true },
  },
 },

 --
 -- Plugins
 --
 plugins =
  {
    -- Base
  ['plugin.appodeal.beta.base']           = { publisherId = 'com.coronalabs' },
  -- Interstitial & Rewarded Video
  ['plugin.appodeal.beta.GoogleAdMob']    = { publisherId = 'com.coronalabs' },
  ['plugin.appodeal.beta.AdColony']       = { publisherId = 'com.coronalabs' },
  ['plugin.appodeal.beta.StartApp']       = { publisherId = 'com.coronalabs' },
  ['plugin.appodeal.beta.AppLovin']       = { publisherId = 'com.coronalabs' },
  ['plugin.appodeal.beta.Chartboost']     = { publisherId = 'com.coronalabs' },
  ['plugin.appodeal.beta.Vungle']         = { publisherId = 'com.coronalabs' },
  ['plugin.appodeal.beta.Unity']          = { publisherId = 'com.coronalabs' },
  ['plugin.appodeal.beta.IronSource']     = { publisherId = 'com.coronalabs' },
  ['plugin.appodeal.beta.InMobi']         = { publisherId = 'com.coronalabs' },
  ['plugin.appodeal.beta.Tapjoy']         = { publisherId = 'com.coronalabs' },
  ['plugin.appodeal.beta.Appnext']        = { publisherId = 'com.coronalabs' },
            --Needs account to be use with Appodeal - Best used for analytics
  --['plugin.appodeal.beta.Flurry'] = { publisherId = 'com.coronalabs' },
            --Needs account to be use with Appodeal
  --['plugin.appodeal.beta.FacebookAudience'] = { publisherId = 'com.coronalabs' },
            --Mobvista renamed to Mintegral = "mintegral"
  --['plugin.appodeal.beta.Mobvista'] = { publisherId = 'com.coronalabs' },
            --Mailru renamed to MyTarget = "my_target"
  --['plugin.appodeal.beta.MyTarget'] = { publisherId = 'com.coronalabs' },

  --['plugin.appodeal.beta.AmazonAds'] = { publisherId = 'com.coronalabs' },
  --['plugin.appodeal.beta.Ogury'] = { publisherId = 'com.coronalabs' },
  --['plugin.appodeal.beta.Yandex'] = { publisherId = 'com.coronalabs' },
  --['plugin.appodeal.beta.TwitterMoPub'] = { publisherId = 'com.coronalabs' },
  },
 --
 -- Project section
 --
 excludeFiles =
 {
  -- Exclude unnecessary files for each platform
  all = { "Icon.png", "Icon-*dpi.png", "Images.xcassets", },
  android = { "LaunchScreen.storyboardc", },
 },
}

I would like to know if I am doing something wrong. I know it must be difficult to understand what 'm doing here but I think there must be an error where the "playBackEnded" is not recognized with the

"test mode = false"

Any help is welcome!

DoDi

 



[TOPIC: post.html]
#2

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,245 posts
  • Corona SDK

I checked two apps that I know the rewards ads are working with Appodeal.

 

First one was updated 3 weeks ago:

if event.data ~= nil and event.type == "rewardedVideo" 
and event.data.finished == true and event.phase == "closed" then
 -- Reward here.

the second one is a little older and closer to your code and this I believe still works in my app with an older version of appodeal:

if event.data ~= nil 
and event.type == "rewardedVideo" 
and event.data.name == "reward" 
and event.phase == "playbackEnded" then
  -- Give reward here.

  • dodi_games likes this

[TOPIC: post.html]
#3

dodi_games

[GLOBAL: userInfoPane.html]
dodi_games
  • Contributor

  • 396 posts
  • Corona SDK

Thanks @agramonte for your quick response. It was really helpful. You have made me think differently. Thanks again. I will implement what you suggest and test the results.

[TOPIC: post.html]
#4

dodi_games

[GLOBAL: userInfoPane.html]
dodi_games
  • Contributor

  • 396 posts
  • Corona SDK

@agramonte I have 2 questions I have no data on any server, or in appodeal, the application configuration in appodeal apps does not require anything about sending data to the event.

Why do I need to verify event.data?

Also event.phase = "closed" Indicates that an ad has been closed. It only applies to interstitial and video static ads, not rewards.

Why do I need to verify this phase?

My game only shows interstitial ads (static and video) and a rewarded video. Can you show an example of what my listener looks like?

Thanks in advance
DoDi

[TOPIC: post.html]
#5

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Corona Geek

  • 1,245 posts
  • Corona SDK

This is just what I do for my apps. It took me weeks of testing to come up with something that reliably will provide a status that the reward ad was completed. You might have a more simple way.  I'll try to share my library tomorrow when I have more time. 




[topic_controls]
[/topic_controls]