The Ads work in the Editor but they don't on the phone

I have implemented the ads, and they work in the editor, however when I build it on the phone, the Continue button never shows an ad, I know the method ContinueButton gets called because the button deactivates after I press it but with no further actions being performed.

1 Like

// This is the code for the AdManager in case it’s needed

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;

public class AdManager : MonoBehaviour, IUnityAdsLoadListener, IUnityAdsShowListener, IUnityAdsInitializationListener
{
    [SerializeField] private bool testMode = false;
    public static AdManager Instance;
    private GameOverHandler gameOverHandler;

#if UNITY_ANDROID
    private string gameId = "5122054";
#elif UNITY_IOS
    private string gameId = "5122055";
#endif

    void Awake()
    {
        if(Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
            Advertisement.Initialize(gameId, testMode, this);
        }
    }

    public void ShowAd(GameOverHandler gameOverHandler)
    {
        this.gameOverHandler = gameOverHandler;
        Advertisement.Show("rewardedVideo", this);
    }

    public void OnUnityAdsAdLoaded(string placementId)
    {
        Debug.Log("Ad Loaded");
    }

    public void OnUnityAdsFailedToLoad(string placementId, UnityAdsLoadError error, string message)
    {
        Debug.Log($"Unity Ads Error: {message}");
    }

    public void OnUnityAdsShowClick(string placementId)
    {
        Debug.Log("Continue Button Pressed");
    }

    public void OnUnityAdsShowComplete(string placementId, UnityAdsShowCompletionState showCompletionState)

    {
        switch(showCompletionState)
        {
            case UnityAdsShowCompletionState.COMPLETED:
                gameOverHandler.ContinueGame();
                break;         
            case UnityAdsShowCompletionState.SKIPPED:
                // Ad was skipped
                break;
            case UnityAdsShowCompletionState.UNKNOWN:
                Debug.Log("Warning! Ad Failed");
                break;
        }  
    }

    public void OnUnityAdsShowFailure(string placementId, UnityAdsShowError error, string message)
    {
        Debug.Log($"Unity Ads Error: {message}");
    }

    public void OnUnityAdsShowStart(string placementId)
    {
        Debug.Log("Ad Start");
    }

    public void OnInitializationComplete()
    {
        Debug.Log("Ad Initialized");
    }

    public void OnInitializationFailed(UnityAdsInitializationError error, string message)
    {
        Debug.Log($"Initialization Failed: {message}");
    }
}

[quote=“Viorel2903, post:2, topic:219145”]

    public void OnInitializationComplete()
    {
        Advertisement.Load("rewardedVideo", this

[quote="Viorel2903, post:2, topic:219145"]
public void OnUnityAdsShowComplete(string placementId, UnityAdsShowCompletionState showCompletionState)
{
    Advertisement.Load("rewardedVideo", this);
    switch(showCompletionState)

Unity recently switched things up requiring us to also manually Load each video… this can’t be done until the Initialzation is complete (until recently, initialization also meant the ads loaded, and completed automagically loaded the next ad, but we have to do it manually now. The above changes reflect where you need to add Loads.

1 Like

It worked. Thank you very much!

Awesome, I’m glad you’re up and running again!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms