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

Banner Ads do not work on IPhone but work on unity

Discussion in 'Unity Ads & User Acquisition' started by shabbacreates, Apr 27, 2019.

  1. shabbacreates

    shabbacreates

    Joined:
    Jan 9, 2019
    Posts:
    7
    Hello,
    So my unity banner ads dont work on my iphone but work on my unity editor.
    Attached is my code. I am really hoping someone can answer this quickly as I want to publish the game soon.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Advertisements;
    5. using UnityEngine.Monetization;
    6.  
    7. public class AdController : MonoBehaviour
    8. {
    9.  
    10.  
    11.     public static string video_placementId = "video";
    12.     public static string ivideo_placementId = "ivideo";
    13.     public static string bannerPlacement = "BannerAd";
    14.     public static bool testMode = false;
    15.  
    16. #if UNITY_IOS
    17.         public static string gameID = "3111651";
    18. #elif UNITY_ANDROID
    19.         public static string gameID = "3111650";
    20. #elif UNITY_EDITOR
    21.     public static string gameID = "1111111";
    22. #endif
    23.  
    24.     //public static string gameID = "3111650";
    25.  
    26.     public static IEnumerator ShowIVideoAdWhenReady()
    27.     {
    28.         while (!Monetization.IsReady(ivideo_placementId))
    29.         {
    30.             yield return new WaitForSeconds(0.25f);
    31.         }
    32.  
    33.         ShowAdPlacementContent ad = null;
    34.         ad = Monetization.GetPlacementContent(ivideo_placementId) as ShowAdPlacementContent;
    35.  
    36.         if (ad != null)
    37.         {
    38.             ad.Show();
    39.         }
    40.     }
    41.  
    42.  
    43.     public static IEnumerator ShowBannerWhenReady()
    44.     {
    45.         while (!Advertisement.IsReady(bannerPlacement))
    46.         {
    47.             yield return new WaitForSeconds(0f);
    48.         }
    49.        Advertisement.Banner.Show(bannerPlacement);
    50.     }
    51. }
    52.