interstitialAd.IsLoaded()始终返回true。当应用程序设备在线时,其工作正常。
public class InsAdBanner : MonoBehaviour
{
public int SceneIndex;
private InterstitialAd interstitialAd;
void Start()
{
this.RequestInterstitial();
}
void RequestInterstitial()
{
string interstitial_ID = "ad_id";
interstitialAd = new InterstitialAd(interstitial_ID);
if (this.interstitialAd != null)
{
this.interstitialAd.Destroy();
}
this.interstitialAd.OnAdLoaded += HandleOnAdLoaded;
this.interstitialAd.OnAdFailedToLoad += HandleOnAdFailedToLoad;
this.interstitialAd.OnAdOpening += HandleOnAdOpened;
this.interstitialAd.OnAdClosed += HandleOnAdClosed;
this.interstitialAd.OnAdLeavingApplication += HandleOnAdLeavingApplication;
AdRequest adRequest = new AdRequest.Builder().Build();
interstitialAd.LoadAd(adRequest);
}
public void Display_InterstitialAD()
{
<!-- plz see this line below -->
if (interstitialAd.IsLoaded())
{
Debug.Log("interstitialAd " + interstitialAd.IsLoaded());
interstitialAd.Show();
}
else {
getOut();
}
}
public void getOut() {
interstitialAd.Destroy();
SceneManager.LoadScene(SceneIndex);
restertAdCounter.restertsAdCouner += 1;
}
#region Interstitial callback handlers
//Handle event
public void HandleOnAdLoaded(object sender, EventArgs args)
{
MonoBehaviour.print("HandleAdLoaded event received");
}
public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
RequestInterstitial();
}
public void HandleOnAdOpened(object sender, EventArgs args)
{
MonoBehaviour.print("HandleAdOpened event received");
}
public void HandleOnAdClosed(object sender, EventArgs args)
{
SceneManager.LoadScene(SceneIndex);
}
public void HandleOnAdLeavingApplication(object sender, EventArgs args)
{
SceneManager.LoadScene(SceneIndex);
}
#endregion
void OnDisable()
{
this.interstitialAd.OnAdLoaded += HandleOnAdLoaded;
this.interstitialAd.OnAdFailedToLoad += HandleOnAdFailedToLoad;
this.interstitialAd.OnAdOpening += HandleOnAdOpened;
this.interstitialAd.OnAdClosed += HandleOnAdClosed;
this.interstitialAd.OnAdLeavingApplication += HandleOnAdLeavingApplication;
}
void OnDestroy()
{
interstitialAd.Destroy();
}
}
我希望它在离线状态下返回false。.当应用程序设备在线时它工作正常..但是在设备离线时却出现此问题..plz帮助..我在google中找不到任何解决方案。
编辑:它也不能在线使用。在添加实际广告代替测试广告后,就会出现此问题。
答案 0 :(得分:0)
解决了我的问题。(尽管我不知道它实际上如何工作)