【问题标题】:Unity admob interstitial suddenly disappear after showingunity admob interstitial 显示后突然消失
【发布时间】:2019-05-01 02:04:51
【问题描述】:

我的 iOS 游戏有以下代码,我只是将它集成到一个空场景中

public class AdController : MonoBehaviour
 {
     void Start()
     {
         print ("------------------ initializing ads --------------------");
         #if UNITY_ANDROID
         string appId = "ca-app-pub-xxxxxxxxxxxxxxxxx~xxxxxxxxxxxxxx";
         #elif UNITY_IPHONE
         string appId = "ca-app-pub-xxxxxxxxxxxxxxxxxx~xxxxxxxxxxxxx";
         #else
         string appId = "unexpected_platform";
         #endif
         // Initialize the Google Mobile Ads SDK.
         MobileAds.Initialize (appId);

                    RequestInterstitial();
     }

     private InterstitialAd interstitial;
     private void RequestInterstitial()
     {

         print ("----------- RequestInterstitial -------------");

         #if UNITY_ANDROID
             string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxxxx";
         #elif UNITY_IPHONE
             string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxx";
         #else
             string adUnitId = "unexpected_platform";
         #endif

         this.interstitial = new InterstitialAd(adUnitId);
         // Called when an ad request has successfully loaded.
         this.interstitial.OnAdLoaded += HandleOnAdLoaded;

         // Create an empty ad request.
         AdRequest request = new AdRequest.Builder().
         AddTestDevice("xxxxxxxxxxmydevicexxxxxxxxxxx")
         .Build();

         // Load the interstitial with the request.
         this.interstitial.LoadAd(request);
     }

     public void HandleOnAdLoaded(object sender, EventArgs args)
     {
         print("HandleAdLoaded event received");
         showInterstitial ();
     }
     void showInterstitial()
     {
         if (this.interstitial.IsLoaded ()) {
             this.interstitial.Show ();
         } else {
             print ("ad not ready yet");
         }
     }
 }

当我的广告展示 1 秒后自动消失。这是解释我的问题的视频链接

https://www.dropbox.com/s/kvrjew0cr8ayqzo/LDFA2437.MP4?dl=0

我做错了什么?

【问题讨论】:

  • 我不太确定,但可能与测试环境有关。用真实的广告和设备试一试,看看你是否有这个问题。
  • 首先我尝试了测试广告,他们有这种行为。然后我放了实时的 admob 单元 ID。我有同样的结果。在视频中,我使用的是实时广告。
  • 但是在您的视频中,您仍然会看到测试广告“这是一个插页式测试广告”。也许这条线:AddTestDevice().
  • 我将移除我的测试设备,然后分享结果
  • 我移除了我的测试设备并尝试使用实时广告,甚至我看到了......它再次像测试广告一样消失了。

标签: c# unity3d admob interstitial


【解决方案1】:

这是救命的答案。我也有同样的问题,并在谷歌群组中找到了答案。如果您使用相同的引用创建一个新的引用(很可能是在展示广告后立即),您将丢失当前的插页式广告并且它会消失。谷歌似乎在他们的后端改变了一些东西,因为我做了同样的事情超过 3 年并且没有发生消失。但是对于最近的sdk,如果您使用相同的插页式对象创建一个新的,您会丢失它。只需在需要时创建一个新的,不要使用以前的引用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-02
    • 1970-01-01
    • 1970-01-01
    • 2022-06-20
    • 1970-01-01
    • 1970-01-01
    • 2012-01-09
    相关资源
    最近更新 更多