Monotouch - iPhone静态加载Admob插页式广告

时间:2013-10-28 20:29:38

标签: ios iphone xamarin.ios admob

我正在尝试使用静态类加载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中收到以下错误:

  

由于已使用插页式广告对象,因此无法发送请求

可以做些什么来解决它?

1 个答案:

答案 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:)