我正在尝试使用静态类加载Admob插页式广告,因此我可以在适当的时间内展示它。
我创建了一个加载非页内广告的方法:
public static void GetInterstitial()
{
interstitial = new GADInterstitial ();
interstitial.AdUnitID = "my_ad_unit_id";
interstitial.LoadRequest (GADRequest.Request);
interstitial.DidReceiveAd += (sender, args) => {
didInterstitialLoad = true;
} ;
interstitial.DidFailToReceiveAd += (object sender, GADInterstitialDidFailToReceiveAdWithErrorEventArgs e) => {
didLoadInterFailed = true;
};
interstitial.DidDismissScreen += (sender, e) => {
//TODO - Handle interstitial dismiss ();
};
}
然后在我的ViewController中:
if (isInterstitialLoaded) {
interstitial.PresentFromRootViewController(this.NavigationController);
}
这是第一次有效,但之后我在interstitial.DidFailToReceiveAd中收到以下错误:
由于已使用插页式广告对象,因此无法发送请求
可以做些什么来解决它?
答案 0 :(得分:1)
当我尝试interstitial.PresentFromRootViewController(this.NavigationController);
解决方案是在解除最后一个广告后重新创建整个插页式广告。因此,在DidDismissScreen
处理程序中,只需再次创建它:
didInterstitialLoad = false;
interstitial = new GADInterstitial ();
interstitial.AdUnitID = "my_ad_unit_id";
interstitial.LoadRequest (GADRequest.Request);
interstitial.DidReceiveAd += (sender, args) => {
didInterstitialLoad = true;
};
HIH:)