Hms Ads Kit integration into Solar2d (Corona) project
To use the plugin please add following to build.settings
{
plugins = {
["plugin.huaweiads"] = {
publisherId = "com.solar2d",
},
},
}
local ads = require "plugin.huaweiads"
local function adListener(event)
print(event.type) -- banner or interstitialAd
print(event.phase) -- loaded, failed, opened, clicked, leave, closed, impression
print(event.isError) -- boolean, true if error occurred
print(event.data) -- error code
end
ads.init(adListener) -- sets listener and inits ad framework
ads.show() -- does nothing, NoOp
ads.showBanner({adId="xx-xxx-xx"}) -- loads and shows banner ad
ads.interstitialAd({adId="xx-xxx-xx"}) -- loads and shows interstitial ad
Plugin is originally made as a demo for this article and moved to Solar2D Free Plugin directory afterwards.