1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. We want to know how you learned Unity! Help us by taking this quick survey and have a chance at a $25 gift card
    Dismiss Notice
  5. Are you an artist or level designer going to Unite Europe? Join our roundtables there to discuss artist features.
    Dismiss Notice
  6. Unity 5.6 is now released.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice

My rewarded video ads are not showing

Discussion in 'Unity Ads' started by witcher101, Mar 20, 2017.

  1. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    179
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4. using UnityEngine.Advertisements;
    5.  
    6. public class UnityAdsButton : MonoBehaviour {
    7.     public string zoneId;
    8.     Button m_Button;
    9.     // Use this for initialization
    10.     void Awake()
    11.     {
    12.         Advertisement.Initialize(zoneId, false);
    13.     }
    14.  
    15.     void Start() {
    16.  
    17.         m_Button = GetComponent<Button>();
    18.         if (m_Button) m_Button.onClick.AddListener(ShowAdPlacement);
    19.  
    20.         StartCoroutine(ShowAdWhenReady());
    21.     }
    22.     IEnumerator ShowAdWhenReady()
    23.     {
    24.         while (!Advertisement.IsReady())
    25.             yield return null;
    26.  
    27.         Advertisement.Show();
    28.     }
    29.     // Update is called once per frame
    30.     void Update()
    31.     {
    32.         if (m_Button)
    33.         {
    34.             if (string.IsNullOrEmpty(zoneId)) zoneId = null;
    35.             m_Button.interactable = Advertisement.IsReady(zoneId);
    36.         }
    37.     }
    38.     void ShowAdPlacement()
    39.     {
    40.         if (string.IsNullOrEmpty(zoneId)) zoneId = null;
    41.         var options = new ShowOptions();
    42.         options.resultCallback = HandleShowResult;
    43.         Advertisement.Show(zoneId, options);
    44.     }
    45.  
    46.     void HandleShowResult(ShowResult result)
    47.     {
    48.         switch (result)
    49.         {
    50.             case ShowResult.Finished:
    51.                 Debug.Log("Video completed. Offer a reward to the player.");
    52.                 break;
    53.             case ShowResult.Skipped:
    54.                 Debug.LogWarning("Video was skipped.");
    55.                 break;
    56.             case ShowResult.Failed:
    57.                 Debug.LogError("Video failed to show.");
    58.                 break;
    59.         }
    60.         if (result == ShowResult.Finished)
    61.         {
    62.             m_Button.interactable = false;
    63.             MainGameController.totalMoneyMade *= 2;
    64.  
    65.         }
    66.     }
    67. }
    68.  
    I am trying to show rewarded videos, it doesnt show up. I used test ads 1st. 1 ad is shown at start of game.
    But rewarded video button remains uninteractable. Then i put test ads to false and still no ads are shown not even the 1st ad when game starts. What am i doing wrong??
     
  2. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    764
    "Advertisement.Initialize(zoneId, false);"

    You should initialize with a game id, not zone id.
     
  3. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    179
    ya i am initialising with gameid from unity dashbaord.
    its just named zoneid in code
     
  4. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    764
    But later in your code, you also use zoneId for Show() method. Concepts:

    Game id: The integer number, which you get from dashboard, e.g. 1000000. This is used for Initialize() call
    Placement id: The "placement" in your game, which can be configured from dashboard. Default placements are typically "video" and "rewardedVideo". This is used for IsReady() and Show() calls

    Seems you have copied most of your code from https://unity3d.com/services/ads/quick-start-guide. But you should make sure to distinguish between gameId and placementId/zoneId.

    /Rasmus