Search Unity

unity ads isready(rewardedVideo) always false on android, help needed

Discussion in 'Unity Ads & User Acquisition' started by enzoravo, Dec 7, 2016.

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

    enzoravo

    Joined:
    Jun 25, 2013
    Posts:
    284
    hello, i'm getting a weird problem, when i have code and tested my ads manager it was working on editor and on my android device.

    now i have upgrade to unity 5.5.0 and i'm testing some new behaviors on my game and it is working on the editor but not in my android device, in the editor i get the unity ads test screen that says that there will be an unity video ads and a button to let it close, but in my android device i don't get anything, i checked and isReady(rewardedVideo) is always false on the android device.

    here is my ads manager code

    Code (csharp):
    1.  
    2.    
    3. using UnityEngine;
    4. using System.Collections;
    5. using UnityEngine.Advertisements;
    6.  
    7. public class ads_manager : MonoBehaviour {
    8.  
    9.   int WhereTo = 0;
    10.   Manager wManager;
    11.  
    12.  
    13.  
    14.   void Start () {
    15.      Advertisement.Initialize("1195102", true);
    16.      wManager = GameObject.Find("Game Manager").GetComponent<Manager>();
    17.  
    18.   }
    19.  
    20.    
    21.   //ifrom ==>0 restart
    22.   //ifrom ==>1 garage
    23.   public void ShowAD(int iFrom)
    24.   {
    25.      WhereTo = iFrom;
    26.      if (Advertisement.IsReady("rewardedVideo"))
    27.      {
    28.         var options = new ShowOptions { resultCallback = HandleShowAD };
    29.         Advertisement.Show("rewardedVideo", options);
    30.      }
    31.   }
    32.  
    33.   public void HandleShowAD(ShowResult result)
    34.   {
    35.      switch (result)
    36.      {
    37.         case ShowResult.Finished:
    38.            Debug.Log("The ad was successfully shown.");
    39.            if (WhereTo == 0)
    40.            {
    41.               wManager.ShowEarnedCoins(5);
    42.               wManager.restart();
    43.            }
    44.            if (WhereTo==1)
    45.            {
    46.               wManager.ShowEarnedCoins(5);
    47.               wManager.garage();
    48.            }
    49.            break;
    50.         case ShowResult.Skipped:
    51.            Debug.Log("The ad was skipped before reaching the end.");
    52.            if (WhereTo == 0)
    53.            {
    54.               wManager.ShowEarnedCoins(0);
    55.               wManager.restart();
    56.            }
    57.            if (WhereTo == 1)
    58.            {
    59.               wManager.ShowEarnedCoins(0);
    60.               wManager.garage();
    61.            }
    62.            break;
    63.         case ShowResult.Failed:
    64.            Debug.LogError("The ad failed to be shown.");
    65.            if (WhereTo == 0)
    66.            {
    67.               wManager.ShowEarnedCoins(0);
    68.               wManager.restart();
    69.            }
    70.            if (WhereTo == 1)
    71.            {
    72.               wManager.ShowEarnedCoins(0);
    73.               wManager.garage();
    74.            }
    75.            break;
    76.         }
    77.      }
    78. }
    79.  
    80.  
    any idead why i'm geting always false on my android device ?

    thanks in advance for all the help.
     
  2. mikaisomaa

    mikaisomaa

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    365
    Hi,

    When are you running ShowAD? Note that it takes at least a few seconds for Unity Ads to initialise when using live ads. During this time - IsReady returns false. It will return false until Unity Ads has initialised.

    A safe approach would be to wait until IsReady() returns true.

    I hope this helps!
     
  3. enzoravo

    enzoravo

    Joined:
    Jun 25, 2013
    Posts:
    284
    hello, i'm showing the ads after the player crash his car, after the game over menu, exactly when the player press restart or go to garage, the ads is called.

    i think the Unity Ads is initialized because i have an empty game object with my ads_manager attached to it, i think the Start function is called for sure because that script is in an object of the scene, is there a way to know if the Unity Ads are initialized ?
     
  4. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    Hello,

    I'm also experiencing this with 5.5.0, in editor and on android device.
     
  5. enzoravo

    enzoravo

    Joined:
    Jun 25, 2013
    Posts:
    284
    at my end, without any changes, sometimes work and sometimes not.

    still don't know the reason of this.
     
  6. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    same issue here after 1 year
     
  7. unity_o4m8mnHno7I3Cw

    unity_o4m8mnHno7I3Cw

    Joined:
    Jul 18, 2019
    Posts:
    1
    waiting worked....
     
Thread Status:
Not open for further replies.