0
votes

I made an android game. I added some ads on it with the test mode off and than I released the game to internal testers and the ads were working so than I fixed some issues in game and released the game for production on playstore.

Now that the game is up on Playstore ads are not working. Will it take some time for ads to show up? There was a popup on unity monetization dashboard that I need to update package name and I did it but ads are still not showing up although playstore listing shows that my app contain ads.

My code is :

public string gameId = "ihavemygameidhere";

public bool testMode = true;
void Start()
{
    // Initialize the Ads service:
    Advertisement.Initialize(gameId, testMode);
}

public void ShowInterstitialAd()
{
    // Check if UnityAds ready before calling Show method:
    if (Advertisement.IsReady())
    {
        Advertisement.Show();
    }
    else
    {
        Debug.Log("Interstitial ad not ready at the moment! Please try again later!");
    }
}
1
The play store listing of ads is a setting set by you in the Google Console, so it will show that there are ads regardless if they are working once that is checked. I would use Android Studio to debug the issue with logcat. I am sure something is being logged that can resolve this. I find it odd that your ads work in a build on the Interal track but do not work in a production environment. They should be near identical.TEEBQNE
@TEEBQNE where is the setting in google console, I am sorry I am new to all thisMalik Nouman
@TEEBQNE I understand but i have no idea how to log but i will look in to itMalik Nouman
@TEEBQNE there is package manager of logcat now in unity so i used that and it says that 2021/05/05 00:26:12.733 17366 19359 Info Unity Interstitial ad not ready at the moment! Please try again later! and i have updated the questionMalik Nouman
Alright, then that would be your issue. I can fix the code you just attached.TEEBQNE

1 Answers

0
votes

When the ad is not ready, that means that the ad server has not yet sent an ad to be seen. I would recommend placing the IsReady() check in a Coroutine, then showing a loading screen UI when the player is waiting. I would also put a fail of some amount of time in case the IsReady() always fails.

[SerializeField] private GameObect LoadingUI = null;
private float waitTime = 5f;

public void ShowInterstitialAd()
{
    StartCoroutine(ShowAd());
}

private IEnumerator ShowAd()
{
    float currentTime = 0.0f;
    
    LoadingUI.SetActive(true);
    
    while(currentTime <= waitTime && !Advertisement.IsReady())
    {
         currenTime += Time.deltaTime;
         yield return null;
    }
    
    // show the ad if it is now ready
    if(Advertisement.IsReady())
    {
         Advertisement.Show();   
    }
    else
    {
        Debug.LogError("Error: Ad was not able to be loaded in " + waitTime + " seconds!");
    }   
    
    LoadingUI.SetActive(false);
}

Make sure to assign some object in the inspector for the LoadingUI object so players can not tap to view ads again or just some UI that blocks all input while the ad is attempting to load. I would use a ScreenOverlay UI as it would be rendered over everything.