Search Unity

I don't receive any small banners with new unity monetisation sdk 3.0 on android and iOS devices

Discussion in 'Unity Ads & User Acquisition' started by unity-huunity, Oct 26, 2018.

  1. unity-huunity

    unity-huunity

    Joined:
    Dec 17, 2013
    Posts:
    10
    Hi! I don't receive any small banners with new unity monetisation sdk 3.0 on android and iOS devices even with test mode on. The "Advertising.Banner.IsLoaded" is always false. However usual fullscreen video ads works fine. Any ideas? I use unity 2018.2.7f1 (mac). I tried different projects. My code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Advertisements;
    5.  
    6. public class AdsScript : MonoBehaviour
    7. {
    8.  
    9.     public void Start()
    10.     {
    11.         Advertisement.Initialize("1234567", true);
    12.         Advertisement.Banner.Load();
    13.     }
    14.  
    15.     public void ShowBannerAd()
    16.     {
    17.         Advertisement.Banner.Show();
    18.     }
    19.  
    20.  
    21.  
    22.     void OnGUI()
    23.     {
    24.         if (GUI.Button(new Rect(10, 10, 50, 50), Advertisement.Banner.isLoaded.ToString()))
    25.             ShowBannerAd();
    26.  
    27.         if (GUI.Button(new Rect(100, 10, 50, 50), "Reload"))
    28.             Advertisement.Banner.Load();
    29.  
    30.     }
    31.  
    32. }
    Android logcat errors:

    Code (LogCat):
    1. 10-26 18:22:59.637 19266-19266/com.Compsdfany.ProductName E/HAL: Dawei load: module=/system/lib/hw/gralloc.msm8953.so
    2. 10-26 18:22:59.895 2672-2960/? E/AudioEffect: set(): AudioFlinger could not create effect, status: -2
    3. 10-26 18:22:59.895 2672-2960/? E/AudioPolicyEffects: addOutputSessionEffects(): failed to create Fx  music_helper on session 1518
    4. 10-26 18:22:59.912 2672-2672/? E/AudioFlinger: open /proc/19266/cmdline error
    5. 10-26 18:22:59.936 2672-2967/? E/audio_hw_dolby: audio_extn_dolby_ds2_set_endpoint: Dolby set endpint :0x2
    6. 10-26 18:23:02.602 2672-2974/? E/AudioFlinger: open /proc/19266/cmdline error
    7. 10-26 18:23:02.616 2672-2960/? E/AudioEffect: set(): AudioFlinger could not create effect, status: -2
    8. 10-26 18:23:02.616 2672-2960/? E/AudioPolicyEffects: addOutputSessionEffects(): failed to create Fx  music_helper on session 1520
    9. 10-26 18:23:02.617 2672-4244/? E/AudioFlinger: open /proc/19266/cmdline error
    10. 10-26 18:23:03.691 19266-19343/com.Compsdfany.ProductName E/cr_VariationsUtils: Failed reading seed file "/data/user/0/com.Compsdfany.ProductName/app_webview/variations_seed_new": /data/user/0/com.Compsdfany.ProductName/app_webview/variations_seed_new: open failed: ENOENT (No such file or directory)
    11. 10-26 18:23:03.967 19266-19362/com.Compsdfany.ProductName E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
    12. 10-26 18:23:05.861 19266-19372/com.Compsdfany.ProductName E/UnityAds: com.unity3d.services.core.api.Sdk.logError() (line:57) :: Init error: {}
    13. 10-26 18:23:10.660 2819-3821/? E/IzatSvc_PassiveLocListener: E/Exiting with error virtual void izat_manager::IzatPassiveLocationListener::onLocationChanged(const izat_manager::IzatLocation*, izat_manager::IzatLocationStatus) line 171 "1"
    14.  
     
  2. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @unity-huunity

    Because the Initialization process is asynchronous, calling LoadBanner immediately after Initialization may cause issues.

    It's best to wait until the banner placement is ready and then show or load the banner.

    (We are aware that our documentation example has a similar problem. We are updating it as soon as we can.)

    You should be able to successfully show banner ads with the following code snippet (or modify it as needed):

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3. using UnityEngine.Advertisements;
    4.  
    5. public class BannerAds : MonoBehaviour
    6. {
    7.     public string bannerPlacement = "banner";
    8.     public bool testMode = false;
    9. #if UNITY_IOS
    10.     public const string gameID = "1234567";
    11. #elif UNITY_ANDROID
    12.     public const string gameID = "1234568";
    13. #elif UNITY_EDITOR
    14.     public const string gameID = "1111111";
    15. #endif
    16.  
    17.     void Start()
    18.     {
    19.         Advertisement.Initialize(gameID, testMode);
    20.         StartCoroutine(ShowBannerWhenReady());
    21.     }
    22.  
    23.     IEnumerator ShowBannerWhenReady()
    24.     {
    25.         while (!Advertisement.IsReady("banner"))
    26.         {
    27.             yield return new WaitForSeconds(0.5f);
    28.         }
    29.         Advertisement.Banner.Show(bannerPlacement);
    30.     }
    31. }
    Please note there are a couple of known issues with banner ads at the moment:

    1. Banners are not currently supported for players in the EU. We are still finalizing our GDPR solution for banners.
    2. There may be times where a banner ad is not available, even if you implemented your code correctly. There is an expected ramp up period, but Unity is working toward fulfilling a majority of ad requests.
     
  3. RossRothenstineU3D

    RossRothenstineU3D

    Unity Technologies

    Joined:
    Oct 26, 2018
    Posts:
    4
    @unity-huunity

    The response above should be correct, but if you'd like to have more control over the Banner (like load it during the title screen, and show it on the game over screen, etc.) then you can use the following code snippet:

    Code (CSharp):
    1.     using System.Collections;
    2.     using UnityEngine;
    3.     using UnityEngine.Advertisements;
    4.  
    5.     public class BannerAds : MonoBehaviour
    6.     {
    7.         public string bannerPlacement = "banner";
    8.         public bool testMode = false;
    9.     #if UNITY_IOS
    10.         public const string gameID = "1234567";
    11.     #elif UNITY_ANDROID
    12.         public const string gameID = "1234568";
    13.     #elif UNITY_EDITOR
    14.         public const string gameID = "1111111";
    15.     #endif
    16.  
    17.         void Start()
    18.         {
    19.             Advertisement.Initialize(gameID, testMode);
    20.             StartCoroutine(LoadBanner());
    21.         }
    22.  
    23.         public bool CanShowBanner()
    24.         {
    25.             return Advertisement.Banner.isLoaded;
    26.         }
    27.  
    28.         public void ShowBanner()
    29.         {
    30.             if (Advertisement.Banner.isLoaded)
    31.             {
    32.                 Advertisement.Banner.Show(bannerPlacement);
    33.             }
    34.         }
    35.  
    36.         IEnumerator LoadBanner()
    37.         {
    38.             while (!Advertisement.IsReady(bannerPlacement))
    39.             {
    40.                 yield return new WaitForSeconds(0.5f);
    41.             }
    42.             // Load won't show the banner, but just load it.
    43.             Advertisement.Banner.Load(bannerPlacement);
    44.         }
    45.     }
    Note the calls to
    Advertisement.Banner.isLoaded
    and
    Advertisement.Banner.Load


    The benefit to this code is that the Banner can be loaded but not shown, and you can show it immediately when you want to.

    RR
     
    tailorjay likes this.
  4. unity-huunity

    unity-huunity

    Joined:
    Dec 17, 2013
    Posts:
    10
    tailorjay likes this.
  5. fortunacus

    fortunacus

    Joined:
    Sep 25, 2013
    Posts:
    43
    how about interstitial ads in unityads 3.0?
    using advertisement.show() still working instead using monetisation.show()?
     
  6. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519