Fuse Ad Listener not getting called?

Hi

I am having problems with the fuse ad listener getting called at any of the event phases.

I have the following code with some native alerts to debug…

function fuseAdListener( event ) native.showAlert( 'title', "Fuse Listener" ) if ( event.isError ) then native.showAlert( 'title', "Fuse error: " .. event.response ) else if ( event.phase == "init" ) then -- Fuse system initialized; load/cache a zone-specific ad fuse.load() elseif ( event.phase == "shown" ) then -- An ad finished showing native.showAlert( 'title', "Fuse Ad shown" ) elseif ( event.phase == "completed" ) then -- User accepted an offer or completed a task for a reward -- The event.payload table contains details about the reward native.showAlert( 'title', event.payload.itemID ) if event.type == "rewarded" then -- do some stuff end end end end fuse.init( fuseAdListener )

Thanks

Hi @sakib.farid,

What else do you do following .init()? Can you show some code where the ad listener should be called? Also, does your code ever reach the listener function in any instance, i.e. do you ever see the first native alert for ( ‘title’, “Fuse Listener” )?

Brent

Hi Brent

So things seem to be working a little better :slight_smile:

The code seems to be getting into the completed phase of the listener but I dont see

native.showAlert( 'title', event.payload.itemID )

Maybe because it is a number and the native alert requires a string ?

Hi again,

Yes, that is very likely. Try using print() statements for debugging instead, or convert the value to a string before passing it to the native alert.

Brent

Hi

So after a little more debugging it turns out that the docs at 

https://docs.coronalabs.com/plugin/fuse/event/adsRequest/payload.html 

which say the payload for a rewarded video should have an itemID property are incorrect.

The property in the payload is rewardItemId.

So to access the item id you would need event.payload.rewardItemId

Thanks @sakib.farid,

I’ll update the docs soon to reflect the correct property name.

Brent

Hi @sakib.farid,

What else do you do following .init()? Can you show some code where the ad listener should be called? Also, does your code ever reach the listener function in any instance, i.e. do you ever see the first native alert for ( ‘title’, “Fuse Listener” )?

Brent

Hi Brent

So things seem to be working a little better :slight_smile:

The code seems to be getting into the completed phase of the listener but I dont see

native.showAlert( 'title', event.payload.itemID )

Maybe because it is a number and the native alert requires a string ?

Hi again,

Yes, that is very likely. Try using print() statements for debugging instead, or convert the value to a string before passing it to the native alert.

Brent

Hi

So after a little more debugging it turns out that the docs at 

https://docs.coronalabs.com/plugin/fuse/event/adsRequest/payload.html 

which say the payload for a rewarded video should have an itemID property are incorrect.

The property in the payload is rewardItemId.

So to access the item id you would need event.payload.rewardItemId

Thanks @sakib.farid,

I’ll update the docs soon to reflect the correct property name.

Brent