Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Ads showing in editor but not on android device

Discussion in 'Unity Ads & User Acquisition' started by ma22be61, May 29, 2019.

Thread Status:
Not open for further replies.
  1. ma22be61

    ma22be61

    Joined:
    Jul 26, 2014
    Posts:
    2
    Hi , I have been trying to implement ads in my game since a while.
    They do work great in editor and Unity shows the test ads.Unfortunately , on any mobile device , it doesn't show either test ads nor real ads.
    Things I tried :
    -Forcing real ads in Unity dashboard
    -Initializing in Update()
    -Re-importing Unity ads asset
    -Disabling and enabling ads
    -Made sure am using the right game ID and set the test mode on false ("1235678" , false)
    -Tried different codes , all worked in Editor but none on any android device
    -Made sure I included advertisement in the script
    Can someone give me a clue where I'm going wrong?
     
  2. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    Can you share your scripts responsible for handling Unity Ads?

    The flow should be this:
    1) Initialise Ads
    2) Wait for them to be ready - Advertisement.IsReady() turns true when you can show ads
    3) Show ads
     
  3. ma22be61

    ma22be61

    Joined:
    Jul 26, 2014
    Posts:
    2
    Here is the code , I tried to put the Initalize both in Start () and Update().
    Keep in mind the test ads do work fine in the editor.

    Code (CSharp):
    1. public class adsManager : MonoBehaviour
    2. {
    3.     playerStats pSt;
    4.     public GameObject rewardPanel;
    5.     public Text rewardText;
    6.     public Text buttonText;
    7.     public shorthandManager shortener;
    8.  
    9.     void Start()
    10.     {
    11.  
    12.         pSt = GameObject.Find("Player").GetComponent<playerStats>();
    13.      
    14.  
    15.     }
    16.  
    17.     void Update()
    18.     {
    19.         Advertisement.Initialize("MYGAMEID", false);
    20.         shortener.checkVal((pSt.goldCoins * 0.25f), buttonText);
    21.         Advertisement.Banner.Load("banner");
    22.         showBanner();
    23.  
    24.     }
    25.  
    26.     void showBanner()
    27.     {
    28.         Advertisement.Banner.Show("banner");
    29.     }
    30.  
    31.     public void goldAd()
    32.     {
    33.         if (Advertisement.IsReady("rewardedVideo"))
    34.         {
    35.             var showOptions = new ShowOptions();
    36.             showOptions.resultCallback += ResultCallback;
    37.  
    38.             Advertisement.Show("rewardedVideo", showOptions);
    39.         }
    40.     }
    41.  
    42.     private void ResultCallback(ShowResult result)
    43.     {
    44.         if (result == ShowResult.Finished)
    45.         {
    46.             rewardPanel.SetActive(true);
    47.             pSt.goldCoins += (pSt.goldCoins * 0.25f);
    48.             rewardText.text = "CONGRATULATIONS! YOU GOT  " +(pSt.goldCoins * 0.25f) + "  COINS!";
    49.         }
    50.         else
    51.         {
    52.             rewardPanel.SetActive(true);
    53.             rewardText.text = "YOU DID NOT FINISH WATCHING THE VIDEO.";
    54.         }
    55.     }
    56.  
    57. }
     
  4. dlolg

    dlolg

    Joined:
    Sep 25, 2018
    Posts:
    13
    I have the same problem. Have you been able to solve it?
     
  5. dlolg

    dlolg

    Joined:
    Sep 25, 2018
    Posts:
    13
  6. SoloOutlaw

    SoloOutlaw

    Joined:
    Feb 29, 2016
    Posts:
    15
    I wouldn’t put the initialise in the update.

    Needs only be called once.

    So put it in Start().
     
Thread Status:
Not open for further replies.