thanks ingemar.
I try to post here the code. There are 2 files
--> 1 for the plugin iself
--> 1 for a displaying UI
It runs on a android 5.1
the version of sdk: 2016.2983
plugin file: Cls_Ads_Trialpay.lua
[lua]
local Cls_Ads_Trialpay = {}
function Cls_Ads_Trialpay:trialPayAdsListener( event )
alert = native.showAlert( “Info”, "trialpay event type = " … event.type , { “OK” } )
if ( event.type == “init” ) then – lecture d’une publicite
if event.isError then
print( "trialpay ad event: initialisation Echec => " … tostring (event.response) )
alert = native.showAlert( “Error”, "Initialisation ad trialpay echec: " … tostring (event.response), { “OK” } )
else
print( “trialpay ad event: init - OK” )
alert = native.showAlert( “Info”, “Initialisation ad trialpay OK”, { “OK” } )
self.isTrialPayLoaded = true;
end
elseif ( event.type == “failed” ) then
print( "trialpay ad event: Erreur => " … tostring ( event.response ) )
alert = native.showAlert( “Error”, "Ad trialpay failed: " … tostring (event.response), { “OK” } )
elseif ( event.type == “closed” ) then
print( "trialpay ad event: Ad Closed " )
alert = native.showAlert( “Info”, “trialpay ad event: Ad Closed”, { “OK” } )
elseif ( event.type == “reward” ) then
print( “trialpay ad event: rewarded video completed”)
alert = native.showAlert( “Info”, “trialpay ad event: rewarded video completed”, { “OK” } )
– event.data for the pairs key/value
end
end
function Cls_Ads_Trialpay:new( APP_KEY_ID, UNIQUE_USER_ID )
o_Cls_Ads_Trialpay = {};
setmetatable( o_Cls_Ads_Trialpay, self )
self.__index = self
self.APP_ID_KEY = APP_KEY_ID
self.USER_ID = UNIQUE_USER_ID
self.trialPay = require( “plugin.trialPay” )
self.isTrialPayLoaded = false;
local function tpListener ( event )
self:trialPayAdsListener( event )
end
self.trialPay.init( tpListener, { appKey = self.APP_ID_KEY, sid = self.USER_ID, APP_ID = self.APP_ID_KEY, UNIQUE_USER_ID = self.USER_ID, app = self.APP_ID_KEY } )
return o_Cls_Ads_Trialpay
end
function Cls_Ads_Trialpay:show ( name_of_ad_type )
if self.isTrialPayLoaded then
self.trialPay ( name_of_ad_type )
else
alert = native.showAlert( “Info”, “trialpay non initialisé - self.APP_ID_KEY = " … self.APP_ID_KEY … " / self.USER_ID =” … self.USER_ID, { “OK” } )
end
end
return Cls_Ads_Trialpay
[/lua]
And in the application UI:
[lua]
– ============================================================================
– TRIALPAY
– ============================================================================
local trialpay = require (“classes.Cls_Ads_Trialpay”)
local instance_trialpay_ads = trialpay:new ( “myKeyIDNumber”, “userID1” )
function showTrialPayAd ()
instance_trialpay_ads:show ( “evt_display_rewarded_vids” )
end
[/lua]
With evt_display_rewarded_vids the name of my event for “Single Offer - Video or Action” - time_bonus_lvl1 as designed in my trialpay dashboard.
I am also having troubles with Appnext so I decided to have a look at the API again and
1- I see that for appnext the release build is written 2992 which I guess is more recent than mine for the sdk no ?
2- I also decided to study the example project provided and noted that all the buttons of widget are calling their function with
[lua]
function myclick( event )
if “ended”==event.phase then
do_something
end
end
[/lua]
In my source code if I print (event.phase) the only answer I get is “began” never “ended” …
So maybe should just i update my version of the SDK …
I’ll give it a try anyway