Revmob weird behavior with LUA or is it me who misses something

Hi there,

I have a question, I don’t think it is related specifically to Revmob, but this behavior is not happening with vungle for example.

I intend to encapsulate the plugins, in customized “objects”.

If I have understood well lua language there is not exact object instances possible, but tables.

So here is what I noticed via Revmob plugin: My test case is 1 UI with 3 buttons: 1 to load a banner ad, 1 to check that the banner is loaded, 1 to show the banner ad.

If I use the revmob plugin directly in the UI: The test banner ad is loading in the UI no problem.

If I use my customized “object” I understand that I can’t even initialize.

My idea is that it might be due to the listener event for the different event phases… I don’t know exactly why neither how design this though;

here is what I tried:

[lua]

local Cls_Ads_Revmob = {}

function Cls_Ads_Revmob:new( APP_KEY_ID)

     o_Cls_Ads_Revmob = {};
     setmetatable( o_Cls_Ads_Revmob, self )
     self.__index = self
    
     self.revmob = require( “plugin.revmob” )
    
     self.app_key_id             =     APP_KEY_ID

    function revmobListener ( event )

      …

    end

    self.revmob.init( revmobListener, { appId = self.app_key_id }  )

   return o_Cls_Ads_Revmob

end

– the getter for the status of the banner

function Cls_Ads_Revmob:checkRevmobBannerReady( )
    return self.revmob.isLoaded(  self.positionBannerID )
end

return Cls_Ads_Revmob

[/lua]

Another version I tried:

[lua]

local Cls_Ads_Revmob = {}

function Cls_Ads_Revmob:revmobListener ( event )

    alert = native.showAlert( “Info”, "revmob - event.phase = " … event.phase … " / event.type = " … tostring(event.type) … " / event.response = " … tostring(event.response), { “OK” } )

end

function Cls_Ads_Revmob:new( APP_KEY_ID)

     o_Cls_Ads_Revmob = {};
     setmetatable( o_Cls_Ads_Revmob, self )
     self.__index = self
    
     self.revmob = require( “plugin.revmob” )
    
     self.app_key_id             =     APP_KEY_ID

    function local_rvmbodListener ( event )
        self:revmobListener( event )
    end

    self.revmob.init( rvmbodListener, { appId = self.app_key_id }  )

   return o_Cls_Ads_Revmob

end

– the getter for the status of the banner

function Cls_Ads_Revmob:checkRevmobBannerReady( )
    return self.revmob.isLoaded(  self.positionBannerID )
end

return Cls_Ads_Revmob

[/lua]

I do never have the alert message in the event listener that is poping…

I’m kind of new to lua I admit, but I have done many “classes” that way with success until this plugin ads.

I have done the same for vungle and it works like a charm. I intend to do the same for personaly and supersonic but if there is glitch in my design then I’d prefer to understand it now please.

I tried your first implementation (I just added print(event.phase) to the listener)

I put the code in a file called ClsAdsRevmob.lua and the listener was called.

In main.lua I just called:

local revmob = require("ClsAdsRevmob") revmob:new("MY\_REVMOB\_APP\_ID")

later in your code you’d call revmob:checkRevmobBannerReady() to check if a banner is loaded.

Sorry, I didn’t see your metadata table and returned object at first.

Since all monetization plugins should only be instantiated once you’d call:

local revmob = require(“ClsAdsRevmob”):new(“MY_REVMOB_APP_ID”)

and later call revmob:checkRevmobBannerReady() to check if a banner is loaded.

Hehe Thank you very much ingemar  :wink:

I had another problem apparently with my app test in Revmob.

The revmob support understood that my first app was kind of in a strange status, and encouraged me to make another one.

everything is fine now, and even better with your input.

Thanks again, great corona support as usual :wink:

I tried your first implementation (I just added print(event.phase) to the listener)

I put the code in a file called ClsAdsRevmob.lua and the listener was called.

In main.lua I just called:

local revmob = require("ClsAdsRevmob") revmob:new("MY\_REVMOB\_APP\_ID")

later in your code you’d call revmob:checkRevmobBannerReady() to check if a banner is loaded.

Sorry, I didn’t see your metadata table and returned object at first.

Since all monetization plugins should only be instantiated once you’d call:

local revmob = require(“ClsAdsRevmob”):new(“MY_REVMOB_APP_ID”)

and later call revmob:checkRevmobBannerReady() to check if a banner is loaded.

Hehe Thank you very much ingemar  :wink:

I had another problem apparently with my app test in Revmob.

The revmob support understood that my first app was kind of in a strange status, and encouraged me to make another one.

everything is fine now, and even better with your input.

Thanks again, great corona support as usual :wink: