Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Appodeal Listener got earwax?
Started by graham.hoyle Aug 10 2018 05:08 AM

11 replies to this topic
rewarded video appodeal

Best Answer graham.hoyle , 11 August 2018 - 01:18 AM

Stupid me?

elseif (phase == "playbackEnded"........

in the appodeal Listener should be :

elseif (event.phase == "playbackEnded"........

So was never detecting "playbackEnded" !!

 

Working OK (for) now... I'll be back!

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

graham.hoyle

[GLOBAL: userInfoPane.html]
graham.hoyle
  • Enthusiast

  • 40 posts
  • Corona SDK

I'm trying to use a "rewarded video"  with the Appodeal plugin to allow a user to continue to a feature of my App. But try as I might I cannot seem get the Listener to act upon "events" in the Listener.

local function appodealListener( event )
 
    if ( event.phase == "init" ) then 
    -- Successful initialization
  
    elseif  event.phase == "failed"  then  -- The ad failed to load
        print( event.type )
        print( event.isError )
        print( event.response )
 
    elseif event.phase == "dataReceived"  then  -- Event data received
        print( event.type )
        print( event.data )

   -- The ad was displayed/played
    elseif (phase == "playbackEnded" or phase == "closed" and event.type == "rewardedVideo") then
        print( "Appodeal event: " .. tostring(event.type) .. " ad displayed" )

        myFeatureFunction()
    end
 end 

So the Listener above is pretty much from the code template except that I want to call myFeatureFunction() after the video has played back and the user closes it.

 

 

my  appodeal.init() is in scene:create and looks like this:

-- Initialize the Appodeal plugin
    appodeal.init(appodealListener, {
    appKey = "MY KEY HERE*************",
    locationTracking = false,
    supportedAdTypes = {"banner", "rewardedVideo"},
    bannerAnimation = true,
    testMode = true
})

and in a in a button Listener I have:

appodeal.show( "rewardedVideo" )

I have set up the plugin correctly in build.settings and the sample video plays without issue. However,  the appodealListener does not perform the call to myFeatureFunction() and does not seem to return to the next line after appodeal.show( "rewardedVideo" ) call.

 

i tried putting:

--in the appodelListener
videoWatched = true

--in the buttonListener
appodeal.show( "rewardedVideo" ) --go play video and set flag

if videoWatched then   --doesn't seem to resume from here as this doesn't work
   myFeatureFunction()
   videoWatched = false
end

The Appodeal test video that I've watched a million times now, says "Good old Mike managed to add just 10 simple lines of code" to get it going....So please don't refer me to reams of documentation as I am dyslexic and find it difficult to absorb huge amounts of mostly irrelevant information.

 

any "concise" info on getting this working would be much appreciated

 

 

 

 



[TOPIC: post.html]
#2

SGS

[GLOBAL: userInfoPane.html]
SGS
  • Corona Geek

  • 1,867 posts
  • Corona SDK

What gets printed?  Anything?

 

Is your listener in the same modual and before the init()?



[TOPIC: post.html]
#3

graham.hoyle

[GLOBAL: userInfoPane.html]
graham.hoyle
  • Enthusiast

  • 40 posts
  • Corona SDK

is that Module?.. yes to both.

 

may have found a comma missing in build.setting... retrying. Zzzzzzz



[TOPIC: post.html]
#4

graham.hoyle

[GLOBAL: userInfoPane.html]
graham.hoyle
  • Enthusiast

  • 40 posts
  • Corona SDK

No. That wasn't it...Still not moving on the myFeatureFunction. Video works OK though. 



[TOPIC: post.html]
#5

graham.hoyle

[GLOBAL: userInfoPane.html]
graham.hoyle
  • Enthusiast

  • 40 posts
  • Corona SDK

If I stick myFeatureFunction() in the code somewhere it performs correctly. Just not being called after the rewarded video completes.



[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,743 posts
  • Corona Staff

Please make this change to your listener function and report what's being printed in the device's console log:


local function appodealListener( event )
    local json = require("json")
    print( json.prettify ( event ) )

    if ( event.phase == "init" ) then 
    -- Successful initialization
  
    elseif  event.phase == "failed"  then  -- The ad failed to load
        print( event.type )
        print( event.isError )
        print( event.response )
 
    elseif event.phase == "dataReceived"  then  -- Event data received
        print( event.type )
        print( event.data )
 
   -- The ad was displayed/played
    elseif (phase == "playbackEnded" or phase == "closed" and event.type == "rewardedVideo") then
        print( "Appodeal event: " .. tostring(event.type) .. " ad displayed" )
 
        myFeatureFunction()
    end
 end 

Thanks

Rob



[TOPIC: post.html]
#7

graham.hoyle

[GLOBAL: userInfoPane.html]
graham.hoyle
  • Enthusiast

  • 40 posts
  • Corona SDK

Hi Rob.

 

This is the output displayed on my Mac..I don't know how to view "device's console log:" is that right?

 

 

Aug 10 07:16:32.705 BUILD SUCCESSFUL
Total time: 8 seconds

Aug 10 07:16:32.843 Android build succeeded in 120 seconds

Aug 10 07:17:09.293 adb I  1103 27290 usb_osx.cpp:259] Found vid=04e8 pid=6860 serial=33007b87980122f9
adb I  1103 27290 usb_osx.cpp:259]
Installing and running Corona Emitter Editor on SM-T800
4293 KB/s (28967643 bytes in 6.588s)
Installing and running Corona Emitter Editor to SM-T800 successfull!
Starting: Intent { cmp=com.gmail.hoyle.gl.CEE/com.ansca.corona.CoronaActivity }

Aug 10 07:17:09.294 ----------  Device Log Starts  ----------

Aug 10 07:17:09.605 SM-T800: Perm

Aug 10 07:17:09.606 ission Denial: getCurrentUser() from pid=18394, uid=10005 requires android.permission.INTERACT_ACROSS_USERS

Aug 10 07:17:09.612 SM-T

Aug 10 07:17:09.612 800: Permission Denial: getCurrentUser() from pid=18423, uid=5010 requires android.permission.INTERACT_ACROSS_USERS

Aug 10 07:17:09.617 SM-T800: Permission Denial: getCur

Aug 10 07:17:09.618 rentUser() from pid=18460, uid=10293 requires android.permission.INTERACT_ACROSS_USERS
SM-T800: Permission Denial: getCurrentUser() from pid=18460, uid=10293 requires android.permission.INTERACT_ACROSS_USERS

Aug 10 07:17:09.848 SM-T800: Pla

Aug 10 07:17:09.849 tform: SM-T800 / ARM Neon / 6.0.1 / Mali-T628 / OpenGL ES 3.1 v1.r7p0-03rel0.1c5439e7f2a6102730b9ed1bddda431c / 2018.3346 / English | GB | en_GB | en

Aug 10 07:17:09.925 SM-T8

Aug 10 07:17:09.926 00: Unable to start service Intent { cmp=com.gmail.hoyle.gl.CEE/shared.google.play.services.base.PackageStateChangedService } U=0: not found

Aug 10 07:17:10.116 SM-T800: plugi

Aug 10 07:17:10.117 n.appodeal: 1.4.3 (SDK: 2.1.11)

Aug 10 07:17:10.403 SM-T800: Memo

Aug 10 07:17:10.403 ry used = 865.044921875

Aug 10 07:17:10.991 SM-T800: {
SM-T80

Aug 10 07:17:10.992 0:   "name":"adsRequest",
SM-T800:   "phase":"init",
SM-T800:   "provider":"appodeal",
SM-T800:   "isError":false
SM-T800: }

Aug 10 07:17:11.277 SM-T800: Sch

Aug 10 07:17:11.278 eduling restart of crashed service com.sec.android.daemonapp/.ap.accuweather.WeatherClockService in 1000ms

Aug 10 07:17:12.616 SM-T800: {
SM-T800:

Aug 10 07:17:12.616    "name":"adsRequest",
SM-T800:   "phase":"loaded",
SM-T800:   "provider":"appodeal",
SM-T800:   "type":"rewardedVideo",
SM-T800:   "isError":false
SM-T800: }

Aug 10 07:17:12.719 SM-T800: {
SM-

Aug 10 07:17:12.720 T800:   "name":"adsRequest",
SM-T800:   "phase":"loaded",
SM-T800:   "provider":"appodeal",
SM-T800:   "type":"banner",
SM-T800:   "isError":false
SM-T800: }

Aug 10 07:17:12.806 SM-T800: Per

Aug 10 07:17:12.807 mission Denial: getCurrentUser() from pid=18713, uid=10154 requires android.permission.INTERACT_ACROSS_USERS

Aug 10 07:17:14.469 SM-T800: Permission Denial: 

Aug 10 07:17:14.470 getCurrentUser() from pid=18798, uid=10247 requires android.permission.INTERACT_ACROSS_USERS

Aug 10 07:17:14.889 SM-T800: Permission

Aug 10 07:17:14.890  Denial: getCurrentUser() from pid=18822, uid=10165 requires android.permission.INTERACT_ACROSS_USERS

Aug 10 07:17:15.990 SM-T800: Permissi

Aug 10 07:17:15.991 on Denial: getCurrentUser() from pid=18897, uid=10041 requires android.permission.INTERACT_ACROSS_USERS

Aug 10 07:17:16.950 SM-T800: Permission Denial: getCur

Aug 10 07:17:16.951 rentUser() from pid=18822, uid=10165 requires android.permission.INTERACT_ACROSS_USERS

Aug 10 07:17:17.363 SM-T800: Permission Denial: getCurrentUser() from pid=18940, uid=10292 requires android.permission.INTERACT_ACROSS_USERS

Aug 10 07:17:17.938 SM-T800: Permission Denial: getCurrentUser() from pid=18965, uid=10164 requires android.permission.INTERACT_ACROSS_USERS

Aug 10 07:17:24.487 SM-T800: {
SM-T80

Aug 10 07:17:24.488 0:   "data":{
SM-T800:     "ERROR":"Appodeal SDK wasn't initialized yet"
SM-T800:   },
SM-T800:   "name":"adsRequest",
SM-T800:   "phase":"dataReceived",
SM-T800:   "provide

Aug 10 07:17:24.488 r":"appodeal",
SM-T800:   "type":"rewardedVideo",
SM-T800:   "isError":false
SM-T800: }
SM-T800: rewardedVideo
SM-T800: table: 0x9aa7f8c0

Aug 10 07:17:24.531 SM-T800: Permission D

Aug 10 07:17:24.531 enial: getCurrentUser() from pid=18460, uid=10293 requires android.permission.INTERACT_ACROSS_USERS

Aug 10 07:17:50.503 SM-T800: Sch

Aug 10 07:17:50.504 eduling restart of crashed service com.sec.factory/.aporiented.FtClient in 1000ms

Aug 10 07:17:55.327 SM-T800: {
SM-T800:  

Aug 10 07:17:55.328  "name":"adsRequest",
SM-T800:   "phase":"playbackBegan",
SM-T800:   "provider":"appodeal",
SM-T800:   "type":"rewardedVideo",
SM-T800:   "isEr

Aug 10 07:17:55.328 ror":false
SM-T800: }
SM-T800: {
SM-T800:   "name":"adsRequest",
SM-T800:   "phase":"loaded",
SM-T800:   "provider":"appodeal",
SM-T800:   "type":"rewardedVideo",
SM-T800:   "isError":false
SM-T800: }

Aug 10 07:17:55.350 S

Aug 10 07:17:55.350 M-T800: {
SM-T800:   "data":{
SM-T800:     "name":"reward",
SM-T800:     "amount":0
SM-T800:   },
SM-T800:   "name":"adsRequest",
SM-T800:   "phase":"playbackEnded",
SM-T800:   "provider":"appodeal",
SM-T800:   "type":"rewardedVideo",
SM-T800:   "isError":false
SM-T800: }
SM-T800: {
SM-T800:   "name":"adsRequest",
SM-T800:   "phase":"closed",
SM-T800:   "provider":"appodeal",
SM-T800:   "type":"rewardedVideo",
SM-T800:   "isError":false
SM-T800: }

I noticed before that I get this error "android.permission.INTERACT_ACROSS_USERS". yet that permission is in my build.settings.. see below.

	android =
	{
		permissions =
		{
			{ name = "com.gmail.hoyle.gl.CEE.permission.C2D_MESSAGE", protectionLevel = "signature" },
		},
		
		usesPermissions =
		{
			"android.permission.INTERNET",
			"android.permission.READ_EXTERNAL_STORAGE",
			"android.permission.ACCESS_NETWORK_STATE",
			"android.permission.WRITE_EXTERNAL_STORAGE",
			"android.permission.INTERACT_ACROSS_USERS",
			"com.google.android.c2dm.permission.RECEIVE",
			".permission.C2D_MESSAGE",
		},
	},



[TOPIC: post.html]
#8

graham.hoyle

[GLOBAL: userInfoPane.html]
graham.hoyle
  • Enthusiast

  • 40 posts
  • Corona SDK

Hi Rob.

 

This is the log from my Huawei P9... doesn't show the errors I get with my Samsung Tab s 10.5 But it still doesn't call my function after the video has played.

 

 

 

Aug 10 08:23:20.590 Installing and running Corona Emitter Editor on EVA-L09
14387 KB/s (28967667 bytes in 1.966s)
Installing and running Corona Emitter Editor to EVA-L09 successfull!
int logctl_get(): open '/dev/hwlog_switch' fail -1, 13. Permission denied

Note: log switch off, only log_main and log_events will have logs!
Starting: Intent { cmp=com.gmail.hoyle.gl.CEE/com.ansca.corona.CoronaActivity }

Aug 10 08:23:20.590 ----------  Device Log Starts  ----------

Aug 10 08:23:20.777 EVA-L09: int logctl_get(): open '/dev/hwlog_sw

Aug 10 08:23:20.778 itch' fail -1, 13. Permission denied
EVA-L09:
EVA-L09: Note: log switch off, only log_

Aug 10 08:23:20.778 main and log_events will have logs!

Aug 10 08:23:21.067 EVA-L09

Aug 10 08:23:21.068 : Platform: EVA-L09 / ARM Neon / 7.0 / Mali-T880 / OpenGL ES 3.2 v1.r12p1-04bet0.76b1d268c59a490265a02c702c8aa55c / 2018.3346 / English | GB | en_GB | en

Aug 10 08:23:21.128 EVA-L09: plugin.appodeal: 1.4.3 (SDK

Aug 10 08:23:21.128 : 2.1.11)

Aug 10 08:23:21.231 EVA-L09: Memor

Aug 10 08:23:21.232 y used = 865.0068359375

Aug 10 08:23:22.318 EVA-L09: {

Aug 10 08:23:22.318 EVA-L09:   "name":"adsRequest",
EVA-L09:   "phase":"init",
EVA-L09:   "provider":"appodeal",
EVA-L09:   "isError":false
EVA-L09: }

Aug 10 08:23:23.364 EVA-L09: {
EVA

Aug 10 08:23:23.365 -L09:   "name":"adsRequest",
EVA-L09:   "phase":"loaded",
EVA-L09:   "provider":"appodeal",
EVA-L09:   "type":"rewardedVideo",
EVA-L09:   "isError":false
EVA-L09: }

Aug 10 08:23:23.840 EVA-L09: {
EVA-

Aug 10 08:23:23.841 L09:   "name":"adsRequest",
EVA-L09:   "phase":"loaded",
EVA-L09:   "provider":"appodeal",
EVA-L09:   "type":"banner",
EVA-L09:   "isError":false
EVA-L09: }

Aug 10 08:23:30.084 EVA-L09: {
EVA-L0

Aug 10 08:23:30.085 9:   "data":{
EVA-L09:     "ERROR":"Appodeal SDK wasn't initialized yet"
EVA-L09:   },
EVA-L09:   "name":"adsRequest",
EVA-L09:   "phase":"dataReceive

Aug 10 08:23:30.086 d",
EVA-L09:   "provider":"appodeal",
EVA-L09:   "type":"rewardedVideo",
EVA-L09:   "isError":false
EVA-L09: }
EVA-L09: re

Aug 10 08:23:30.087 wardedVideo
EVA-L09: table: 0xc2bf6b40

Aug 10 08:23:59.208 EVA-L09: {
EVA-L09:   "name":"a

Aug 10 08:23:59.209 dsRequest",
EVA-L09:   "phase":"playbackBegan",
EVA-L09:   "provider":"appodeal",
EVA-L09:   "type":"rewardedVideo",
EVA-L09:   "isError":false
EVA-L09: }

Aug 10 08:23:59.224 EVA-L09: {
EVA-L09:

Aug 10 08:23:59.225    "name":"adsRequest",
EVA-L09:   "phase":"loaded",
EVA-L09:   "provider":"appodeal",
EVA-L09:   "type":"rewardedVideo",
EVA-L09:   "isError":false
EVA-L09: }
EVA-L09: {
EVA-L09:   "data"

Aug 10 08:23:59.226 :{
EVA-L09:     "name":"reward",
EVA-L09:     "amount":0
EVA-L09:   },
EVA-L09:   "name":"adsRequest",
EVA-L09:   "phase":"playbackEnded",
EVA-L09:   "provider":"appodeal",
EVA-L09:   "type":"rewardedVideo",
EVA-L09:   "isError":false
EVA-L09: }
EVA-L09: {
EVA-L09:   "name":"adsReq

Aug 10 08:23:59.226 uest",
EVA-L09:   "phase":"closed",
EVA-L09:   "provider":"appodeal",
EVA-L09:   "type":"rewardedVideo",
EVA-L09:   "isError":false
EVA-L09: }



[TOPIC: post.html]
#9

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,743 posts
  • Corona Staff

Lets not worry about the INTERACT_ACROSS_USERS error for now, this appears to be something that may be Samsung or Android 4.4.x related.

 

The problem is you're trying to make Appodeal calls before the system has initialized, but it appears that you have. If you don't mind, can you post your code where you're setting up your ad code and calling the various .load() and .show() code?

 

Thanks

Rob



[TOPIC: post.html]
#10

graham.hoyle

[GLOBAL: userInfoPane.html]
graham.hoyle
  • Enthusiast

  • 40 posts
  • Corona SDK

Thanks Rob.

 

So, at the top of the scene I have:

local appodeal = require( "plugin.appodeal" )

then I have: 

-- Initialize the Appodeal plugin
    appodeal.init(appodealListener, {
    appKey = "MY KEY IN HERE***********",
    locationTracking = false,
    supportedAdTypes = {"banner", "rewardedVideo"},
    bannerAnimation = true,
    testMode = true
})

at the very beginning of scene:create(), which does quite a bit including setting up some buttons for the user. These are handled here below where the "handleButtonEvent( event )" detects which button was pressed and if it's the "mail" button calls "onComplete( event )" which sets a yes/No Alert as to wether they want to continue to the video.

 

If yes then appodeal.show( "rewardedVideo" ) is called from here. (The commented out section is an alternative to calling "myFeatureFunction() inside the appodealListener by setting "watchedAd" to true, which doesn't work either.)

local function onComplete( event )
    if ( event.action == "clicked" ) then
        local i = event.index
        if ( i == 1 ) then           
            appodeal.show( "rewardedVideo" )
            appodeal.getRewardParameters()
                -- if  watchedAd then
                --         myFeatureFunction() 
                --     watchedAd = false   
                -- end
        elseif ( i == 2 ) then
             --do nothing if No Thanks
        end
    end
    return true
 end
 
--
local function handleButtonEvent( event )

    if ( "ended" == event.phase ) then

        if event.target.id == "mail" then

            local msg = "In order to continue a short ad video will now play."..
                        "The email dialog will open on completion. Is that OK?  "..
                        "You may want to lower the volume?"
            local alert = native.showAlert("Ad Warning!",  msg, { "Yes", "No Thanks!" }, onComplete )
     
        elseif event.target.id == "selectParticle" then
            print("select particle")
        elseif event.target.id == "exampleListButton" then
            print("exampleListButton")
            transition.to( exampleList, { time=500, alpha=1 } )
            transition.to( exampleList, { time=500, delay=4000, alpha=0} )        
        end    
    end
    return true
 end 

I do not have a .load() as the docs said it is done automatically and the video is always ready to play. It's afterwards that is the problem.



[TOPIC: post.html]
#11

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,743 posts
  • Corona Staff

I don't recommend initializing ad plugins inside a scene. This is best done in main.lua or a module loaded by main.lua so you can guarantee it only happens once. 

 

Then you should be using your appodealListener() function to test if the rewardedVideo was completed and then from there, call your code to process your reward.

 

Rob



[TOPIC: post.html]
#12

graham.hoyle

[GLOBAL: userInfoPane.html]
graham.hoyle
  • Enthusiast

  • 40 posts
  • Corona SDK

  Best Answer

Stupid me?

elseif (phase == "playbackEnded"........

in the appodeal Listener should be :

elseif (event.phase == "playbackEnded"........

So was never detecting "playbackEnded" !!

 

Working OK (for) now... I'll be back!




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: rewarded video, appodeal