Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity still showing test ads in production version.

Discussion in 'Unity Ads & User Acquisition' started by Maximo123213, Mar 5, 2021.

  1. Maximo123213

    Maximo123213

    Joined:
    Dec 12, 2018
    Posts:
    6
    I made an app that is currently active in the Play Store, checked "Force test mode OFF (i.e. use real ads) for all devices" and unchecked "enable test ads" in the unity service window. Also, the ad banner never appeared, I don't know if it's because I did a wrong implementation, thanks in advance.

    This is my code

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Advertisements;
    5.  
    6.  
    7. public class adv: MonoBehaviour
    8. {
    9.     string gameId = "xxxxxxx";
    10.     bool testMode = false;
    11.     public string placementId = "bannerPlacement";
    12.     public string placementIds = "video";
    13.  
    14.     void Start()
    15.     {
    16.         Advertisement.Initialize(gameId, testMode);
    17.  
    18.         StartCoroutine(ShowBannerWhenReady());  
    19.     }
    20.  
    21.     void Update()
    22.     {
    23.         if (PlayerPrefs.GetFloat("ADV") >= 10)
    24.         {
    25.            
    26.             ShowInterstitialAd();
    27.  
    28.             PlayerPrefs.SetFloat("ADV", 0);
    29.         }
    30.     }
    31.     public void ShowInterstitialAd()
    32.     {
    33.         if (Advertisement.IsReady(placementIds))
    34.         {
    35.             Advertisement.Show(placementIds);          
    36.         }
    37.         else
    38.         {
    39.             Debug.Log("Interstitial ad not ready at the moment! Please try again later!");
    40.         }
    41.     }
    42.     IEnumerator ShowBannerWhenReady()
    43.     {
    44.         while (Advertisement.IsReady(placementId))
    45.         {
    46.             yield return new WaitForSeconds(0.5f);
    47.         }
    48.         Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
    49.         Advertisement.Banner.Show(placementId);
    50.     }
    51.  
    52.     public void OnUnityAdsDidFinish(string placementIds, ShowResult showResult)
    53.     {
    54.            
    55.         if (showResult == ShowResult.Failed)
    56.         {
    57.             ShowInterstitialAd();
    58.         }
    59.  
    60.     }
    61.  
    62. }
     
  2. Unity_Adamski

    Unity_Adamski

    Unity Technologies

    Joined:
    Jul 20, 2020
    Posts:
    110
    Sadly this is a very common mistake. There are two different ways you can disable testMode in your application.

    The first method will require you to do another build, to do this you must locate the testMode toggle in the services window and disable it, then you must pass through the false boolean for testMode in your Advertisement.Intitialize() function. Also if your testMode variable is a public variable, or serializable, ensure that it is also set to false in the inspector panel.

    The second method will not require you to do a new build however it will disable testMode regardless of what boolean you pass to the SDK. To do this you will need to go to your project in your Unity Dashboard > Project Settings > TestMode, set this to 'Override Client Test Mode' and then 'Force Test Mode OFF'. This will force testMode off on all builds of your app regardless of the settings in your code.
     
    sladetheleveller and ivanscream like this.
  3. reahaas

    reahaas

    Joined:
    Jan 26, 2019
    Posts:
    2
    Thank you very much, solved like a charm!