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 Banner ads not show real ads in devices.

Discussion in 'Unity Ads & User Acquisition' started by Deleted User, May 24, 2019.

  1. Deleted User

    Deleted User

    Guest

    Hi,

    Unity Banner ads only work in Editor, and does not deliver real ads in devices with android system. Is there an issue with the banner ads? Or there are simply no real banner ads to display yet?

    Script:
    Code (CSharp):
    1. *using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine.Advertisements;
    4. using UnityEngine.Monetization;
    5. using UnityEngine.UI;
    6. using UnityEngine;
    7.  
    8. public class AdManager : MonoBehaviour
    9. {
    10.     string bannerPlacement = "bannerAd";
    11.     string rewardPlacement = "rewardedVideo";
    12.     string videoPlacement = "video";
    13.  
    14.     bool testMode = false;
    15.  
    16.     public const string gameID = "xxxxxxx";
    17.  
    18.     public Text Testy;
    19.  
    20.     void Start()
    21.     {
    22.         startTime = Time.time;
    23.  
    24.         Advertisement.Initialize(gameID, testMode);
    25.        
    26.         if (Monetization.isSupported) {
    27.             Monetization.Initialize(gameID, testMode);
    28.         }
    29.  
    30.         StartCoroutine(ShowBannerWhenReady());
    31.     }
    32.  
    33.     public void ShowVideoAd() {
    34.         ShowAdPlacementContent ad = null;
    35.         ad = Monetization.GetPlacementContent(videoPlacement) as ShowAdPlacementContent;
    36.         if (ad != null) {
    37.             ad.Show();
    38.         }
    39.     }
    40.     public bool RewardAdIsReady() {
    41.         if (Monetization.IsReady(rewardPlacement)) {
    42.             return true;
    43.         }
    44.         else { return false; }
    45.     }
    46.     public void ShowRewardAd() {
    47.         ShowAdPlacementContent ad = null;
    48.         ad = Monetization.GetPlacementContent(rewardPlacement) as ShowAdPlacementContent;
    49.  
    50.         if (ad != null) {
    51.             ad.Show(HandleShowResult);
    52.         }
    53.     }
    54.  
    55.     void HandleShowResult(UnityEngine.Monetization.ShowResult result) {
    56.         if (result == UnityEngine.Monetization.ShowResult.Finished) {
    57.             //
    58.         }
    59.     }
    60.  
    61.     IEnumerator ShowBannerWhenReady() {
    62.         while (!Advertisement.IsReady("bannerAd")) {
    63.             yield return new WaitForSeconds(0.5f);
    64.         }
    65.         Advertisement.Banner.Show(bannerPlacement);
    66.     }
    67.  
    68.     public void HideBannerAd() {
    69.         Advertisement.Banner.Hide();
    70.     }
    71. }