为什么我的AdMob插页式广告仅展示一次?

时间:2017-10-08 19:08:59

标签: android unity3d admob interstitial

我在我的应用上使用了admob interstitial。我只能显示插页式广告一次,但我不知道如何申请新的插播广告。租赁帮助我!

我的代码如下?

  using UnityEngine;

使用GoogleMobileAds.Api;

公共类AdsMnager:MonoBehaviour {

public static AdsMnager Instance { 
    get ; 
    set;
}
public bool InterstitialLoaded = false;
public bool InterstitialClosed = false ;
const string InterstitialAdId ="ca-app-pub-3940256099942544/1033173712";
const string BannerAdId = "ca-app-pub-3940256099942544/6300978111";
InterstitialAd interstitialAd;
AdRequest request;
private BannerView bannerView;


private void Awake()
{
    if (Instance == null)
        Instance = this;
    else
        Destroy (gameObject);
    DontDestroyOnLoad (gameObject);
    interstitialAd = new InterstitialAd (InterstitialAdId);

    Showbanner ();
    request = new AdRequest.Builder ().Build ();
    interstitialAd.LoadAd (request);
}
public void RequestBanner()
{
    bannerView = new BannerView (BannerAdId, AdSize.Banner, AdPosition.Bottom);
    AdRequest request = new AdRequest.Builder ().Build ();
    bannerView.LoadAd (request);
    bannerView.Show ();

}
public void Showbanner()
{
    if (bannerView == null)
        RequestBanner ();
}

public void ShowInterstitial()
{
    request = new AdRequest.Builder ().Build ();
    interstitialAd.LoadAd (request);
    if (interstitialAd.IsLoaded ()) {

        InterstitialLoaded = true;
        interstitialAd.Show ();
    } else {

    }

    interstitialAd.OnAdClosed += InterstitialAd_onAdClosed;
}

private void InterstitialAd_onAdClosed (object sender , System.EventArgs e)
{
    InterstitialLoaded = false;
    InterstitialClosed = true;
}
}

提前致谢。

1 个答案:

答案 0 :(得分:0)

您可以在#onAdClosed()回调方法中申请新广告。只需修改#InterstitialAd_onAdClosed()方法即可:

private void InterstitialAd_onAdClosed (object sender , System.EventArgs e)
{
    InterstitialLoaded = false;
    InterstitialClosed = true;
    interstitialAd.LoadAd(new AdRequest.Builder().Build())

}