Ads Wrapper is a wrapper for advertising services. It allows you to use one interface for different services and show ads from different sources. We use this extension all the time in our projects. It simplifies development for different platforms and allows you to create advertising mediation.
There is no direct function.
You can manually save the value when using the ad function. Example:
local is_rewarded_loaded = false
ads_wrapper.load_rewarded(function(response)
if response.result == events.SUCCESS then
is_rewarded_loaded = true
end
end)
Or you can find it out for a specific network:
local admob_network = require("ads_wrapper.ads_networks.admob")
admob_network.is_rewarded_loaded()
admob_network.is_interstitial_loaded()
admob_network.is_banner_loaded()
I have not come across a situation where they were needed. I can add such functions for the network pointed to by the mediator, if you need them specifically in ads_wrapper.
Haven’t worked with Appodeal yet. Maybe I’ll take a look in my free time.
You can add the service you need yourself. You need to implement these functions:
Fixed M.show_banner(callback) and M.hide_banner(callback) functions for networks.
Now they should call a function, not return a value. These functions need to be fixed if you use your own networks.
hello please what are the steps to add ads to my code i already fetch the library and i am a quite slow learner and i don’t understand examples so how to add interstitial ads or banner ads using unity ads
well it’s not showing ads this is my gui_script:
local ads_wrapper = require("ads_wrapper.ads_wrapper")
local unity = require("ads_wrapper.ads_networks.unity")
local platform = require("ads_wrapper.platform")
local unity_net_id = ads_wrapper.register_network(unity, {
ids = {[platform.PL_ANDROID] = "5283423", [platform.PL_IOS] = "5283422"}, ---Set your id. These are test keys
[ads_wrapper.T_REWARDED] = "rewardedVideo",
[ads_wrapper.T_INTERSTITIAL] = "video",
[ads_wrapper.T_BANNER] = {id = "banner", size = {width = 720, height = 90}, position = unityads.BANNER_POSITION_BOTTOM_RIGHT}
})
function init(self)
msg.post(".", "acquire_input_focus")
ads_wrapper.setup_video({ { id = unity_net_id , count = 1 } })
ads_wrapper.setup_banner({ { id = unity_net_id , count = 1 } })
ads_wrapper.init(true, true, function(response)
pprint(response)
end)
end
function final(self)
end
function update(self, dt)
-- Add update code here
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
end
function on_message(self, message_id, message, sender)
-- Add message-handling code here
-- Learn more: https://defold.com/manuals/message-passing/
-- Remove this function if not needed
end
function on_input(self, action_id, action)
if action_id == hash("touch") and action.pressed then -- <2>
local button = gui.get_node("button") -- <3>
local text = gui.get_node("text") -- <4>
if gui.pick_node(button, action.x, action.y) then -- <5>
gui.set_text(text, "HELLO!") -- <6>
ads_wrapper.show_interstitial(callback)
end
end
end
function on_reload(self)
-- Add reload-handling code here
-- Learn more: https://defold.com/manuals/hot-reload/
-- Remove this function if not needed
end
We need to look at the errors in the android.
If you have compiled a debug build and are connected to the same network, then you can select a mobile one and see what the errors are there: