Hello!
Although the initialisation is successful I can’t make the ads to load.
It works just fine on Android but not on iOS (plugin.unityads.v4).
Any thoughts.
local A = {}
local initiTrue = 0
local isLoadingInterstitial = false
local isLoadingRewarded = false
local retryCountInterstitial = 0
local retryCountRewarded = 0
local maxRetries = 5
local unityads = require( "plugin.unityads.v4" )
function A:initializeAds()
-- Unity Ads Listener
unityListener = function(event)
if event.phase == "init" then
-- Successful initialization
if not unityads.isLoaded("Interstitial_iOS") then
unityads.load("Interstitial_iOS")
end
if not unityads.isLoaded("Rewarded_iOS") then
unityads.load("Rewarded_iOS")
end
-- Set user consention
unityads.setHasUserConsent( true )
initiTrue = 1
elseif event.phase == "loaded" then
elseif event.phase == "displayed" then
if not unityads.isLoaded("Interstitial_iOS") then
unityads.load("Interstitial_iOS")
end
if not unityads.isLoaded("Rewarded_iOS") then
unityads.load("Rewarded_iOS")
end
elseif event.phase == "completed" then
elseif event.phase == "failed" and initiTrue == 1 then
if not unityads.isLoaded("Interstitial_iOS") and retryCountInterstitial < maxRetries and not isLoadingInterstitial then
retryCountInterstitial = retryCountInterstitial + 1
isLoadingInterstitial = true
timer.performWithDelay(5000, function()
unityads.load("Interstitial_iOS")
isLoadingInterstitial = false
end)
end
if not unityads.isLoaded("Rewarded_iOS") and retryCountRewarded < maxRetries and not isLoadingRewarded then
retryCountRewarded = retryCountRewarded + 1
isLoadingRewarded = true
timer.performWithDelay(5000, function()
unityads.load("Rewarded_iOS")
isLoadingRewarded = false
end)
end
end
end
-- Flag for personalized ads before initialize
unityads.setPersonalizedAds( true )
-- Initialize Unity Ads
unityads.init(unityListener, { gameId = "xxx", testMode = false })
end
-- Return it all to the game
return A