如果admob横幅广告未加载,我尝试加载自定义横幅广告(其他游戏横幅广告),并在加载横幅广告时销毁自定义广告。我写了一个代码,但是没有用。 这是代码。
public class AdScript : MonoBehaviour {
private BannerView bannerView;
void Start ()
{
this.showBannerAd();
}
private void showBannerAd()
{
string adID = "ca-app-pub-9238312914970318/8415382856";
bannerView = new BannerView(adID, AdSize.SmartBanner, AdPosition.Bottom);
bannerView.OnAdFailedToLoad += HandleOnAdFailedToLoad;
bannerView.OnAdLoaded += HandleOnAdLoaded;
AdRequest request = new AdRequest.Builder().Build();
bannerView.LoadAd(request);
}
public void HandleOnAdLoaded(object sender, EventArgs args)
{
print("HandleAdLoaded event received");
}
public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
print("HandleFailedToReceiveAd event received with message: "
+ args.Message);
// writing custom ad code here.. if admob banner ad not loaded
}
}
答案 0 :(得分:0)
尝试销毁横幅,然后初始化自定义广告横幅,设置计时器以尝试再次启动admob广告