Search Unity

Units Ads Down/Outage tonight???

Discussion in 'Unity Ads & User Acquisition' started by OliverAge24Games, Feb 10, 2019.

  1. OliverAge24Games

    OliverAge24Games

    Joined:
    Jun 13, 2014
    Posts:
    16
    Hey,

    I just did a bunch of different builds of my game with Unity Ads in, while streaming development live on Twitch.

    None of the viewers could get the game working it kept freezing at start up and crashing.

    I turned the stream off to investigate, and everything seemed to make sense - It all worked fine in Unity Editor, just not on android phones.

    Then, about 10 minutes ago, it suddenly just started working - I checked with my viewers that had downloaded the earlier builds, and they were all suddenly working again.

    The exact builds that were crashing about an hour ago, are now working - Nothing else had changed.

    Did Unity Ads go down/have outage during this time?

    Is that normal? I don't want that to happen once I've released the game!

    Cheers,
    Oliver
     
  2. OliverAge24Games

    OliverAge24Games

    Joined:
    Jun 13, 2014
    Posts:
    16
    Okay, so video ads are working in Unity, but not on Android...
     
  3. OliverAge24Games

    OliverAge24Games

    Joined:
    Jun 13, 2014
    Posts:
    16
    Here's an APK:
    https://www.dropbox.com/s/f3d07hgvq642692/SnekGamePhoneAlpha8.apk?dl=0

    Here's the code I use for Unity Ads (Based on the examples) - I've edited out my GameIDs incase they're meant to be private:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using UnityEngine.Monetization;
    4.  
    5. [RequireComponent(typeof(Button))]
    6. public class UnityAdsButton : MonoBehaviour
    7. {
    8.  
    9.     public string placementId = "rewardedVideo";
    10.     private Button adButton;
    11.  
    12. #if UNITY_IOS
    13.    private string gameId = "DELETED THIS INCASE ITS PRIVATE";
    14. #elif UNITY_ANDROID
    15.     private string gameId = "DELETED THIS INCASE ITS PRIVATE";
    16. #endif
    17.  
    18.     void OnEnable()
    19.     {
    20.         adButton = GetComponent<Button>();
    21.         if (adButton)
    22.         {
    23.             adButton.onClick.AddListener(ShowAd);
    24.         }
    25.  
    26.         if (Monetization.isSupported)
    27.         {
    28.             Monetization.Initialize(gameId, true);
    29.         }
    30.     }
    31.  
    32.     void Update()
    33.     {
    34.         if (adButton)
    35.         {
    36.             adButton.interactable = Monetization.IsReady(placementId);
    37.         }
    38.     }
    39.  
    40.     void ShowAd()
    41.     {
    42.         ShowAdCallbacks options = new ShowAdCallbacks();
    43.         options.finishCallback = HandleShowResult;
    44.         ShowAdPlacementContent ad = Monetization.GetPlacementContent(placementId) as ShowAdPlacementContent;
    45.         ad.Show(options);
    46.     }
    47.  
    48.     void HandleShowResult(ShowResult result)
    49.     {
    50.         if (result == ShowResult.Finished)
    51.         {
    52.             // Reward the player
    53.             GameManager.globalGameManager.ContinueLevel();
    54.         }
    55.         else if (result == ShowResult.Skipped)
    56.         {
    57.             Debug.LogWarning("The player skipped the video - DO NOT REWARD!");
    58.         }
    59.         else if (result == ShowResult.Failed)
    60.         {
    61.             Debug.LogError("Video failed to show");
    62.         }
    63.     }
    64. }

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3. using UnityEngine.Advertisements;
    4. using UnityEngine.Monetization;
    5.  
    6. public class BannerAds : MonoBehaviour
    7. {
    8.  
    9.     public string bannerPlacement = "banner";
    10.     public bool testMode = false;
    11.  
    12. #if UNITY_IOS
    13.    private string gameId = "EDITED THIS OUT";
    14. #elif UNITY_ANDROID
    15.     private string gameId = "EDITED THIS OUT";
    16. #endif
    17.  
    18.     void OnEnable()
    19.     {
    20.         if (Monetization.isSupported)
    21.         {
    22.             Monetization.Initialize(gameId, true);
    23.         }
    24.         Advertisement.Initialize(gameId, testMode);
    25.         StartCoroutine(ShowBannerWhenReady());
    26.  
    27.     }
    28.  
    29.     IEnumerator ShowBannerWhenReady()
    30.     {
    31.         while (!Advertisement.IsReady(bannerPlacement))
    32.         {
    33.             yield return new WaitForSeconds(0.5f);
    34.         }
    35.         Advertisement.Banner.Show(bannerPlacement);
    36.         Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
    37.     }
    38. }
     
  4. OliverAge24Games

    OliverAge24Games

    Joined:
    Jun 13, 2014
    Posts:
    16
    Okay, narrowing it down more - I guess:

    Everytime, I show a banner app in Unity Editor, it shows up. On Android, it only shows the banner ad the FIRST time I try to show one, then stops showing.

    Video ads play everytime, in Unity Editor... but never play on Android.
     
  5. OliverAge24Games

    OliverAge24Games

    Joined:
    Jun 13, 2014
    Posts:
    16
    Deleted the Package Manager version, and downloaded the Asset Store version, and now Rewarded Video Ads are working... no banners though.

    Progress!

    Should Banners be working?

    I changed the code to this - Works perfectly in Editor, not on phone:

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3. using UnityEngine.Advertisements;
    4. using UnityEngine.Monetization;
    5.  
    6. public class BannerAds : MonoBehaviour
    7. {
    8.     public string bannerPlacement = "banner";
    9.     public bool testMode = false;
    10.     public bool adShown = false;
    11.  
    12. #if UNITY_IOS
    13.    private string gameId = "HIDDEN";
    14. #elif UNITY_ANDROID
    15.     private string gameId = "HIDDEN";
    16. #endif
    17.     void OnEnable()
    18.     {
    19.         adShown = false;
    20.     }
    21.     private void Update()
    22.     {
    23.         if (Monetization.isSupported)
    24.         {
    25.             if (!Monetization.isInitialized)
    26.             {
    27.                 Monetization.Initialize(gameId, testMode);
    28.             }
    29.         }
    30.         if (!Advertisement.isInitialized)
    31.         {
    32.             Advertisement.Initialize(gameId, testMode);
    33.         }
    34.         if (Advertisement.IsReady(bannerPlacement) && !adShown)
    35.         {
    36.             Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
    37.             Advertisement.Banner.Show(bannerPlacement);
    38.             adShown = true;
    39.         }
    40.     }
    41.     private void OnDisable()
    42.     {
    43.         if (adShown)
    44.         {
    45.             Advertisement.Banner.Hide(true);
    46.             adShown = false;
    47.         }
    48.     }
    49. }
     
  6. OliverAge24Games

    OliverAge24Games

    Joined:
    Jun 13, 2014
    Posts:
    16
    Update - All fixed - I switched TestMode back on, and the Unity Ads are showing on banner + video ads. (I guess the reason the banner ads weren't showing when I switched in the previous post were because there are none available right now?)

    The solution was just to ditch the Package Manager version and use the Unity Asset Store version.

    You guys should disable the Package Manager version if it's bust though, this cost me loads of time and was really annoying.
     
  7. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Our stats for last 24 hours, no outages from our end:
    upload_2019-2-10_19-10-23.png

    We're still working with advertisers to ensure sufficient number of banner ads, depending on players locations, they might not always receive banner ads.

    We're working on getting package manager version updated, so there would only be one method of integrating last available Ads SDK version. For now, it's fine to use Asset Store to get latest package.

    /Rasmus