Unity Ads Not Loading On iOS

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
1 Like

Hello,

I’d start with the simple:

  1. Check the contents of the app-ads.txt file;
  2. Check the contents of the SKAdNetwork listing;
  3. Make sure the marketing URL is listed on the app’s App Store page;
  4. Add the testing device to the appropriate list;
  5. Set ad serving to test mode if testing.

@VLD thank you for your reply!

Are you actively using Unity Ads plugin in your iOS applications with recent updates?
I’m trying to rule out the possibility of plugin related issues because it’s not updated for some time now.

Also I just saw that the issue is not that the ads are not loading.
Init phase is not successful.
I get this error: Unity Ads WebApp creation failed
Anyone knows what that means?

This works fine for me… you code looks odd, try making your listener it’s own function (i.e. not part of another function)

Hi @solar_dev, thank you for the reply!
Listener is part of another function because its a module :D.
I did try just having a simple function in main.lua but I had the same issue.
Everything is good on Android but doesn’t work on iOS.

Could you share your working code?

A module can have hundreds of functions!

Try this and print the event properties

local A = {}

local function unityListener(event)  <--move here
    print("phase = "..event.phase)
end

function A:initializeAds()
    unityads.setPersonalizedAds( true )
    unityads.init(unityListener, { gameId = "xxx", testMode = false })
end
	
return A
1 Like

Ok, thank you!!

Same issue no matter what I do.
Init phase is not successful.
I get this error: Unity Ads WebApp creation failed.

I wonder why the same code works fine on Android but not on iOS!