コード例 #1
0
ファイル: AppDelegate.cs プロジェクト: tomschwiha/AdMobBuddy
        void AddToView()
        {
            if (interstitialRequested)
            {
                return;
            }

            if (adInterstitial == null)
            {
                adInterstitial = new GADInterstitial(intersitialId);

                adInterstitial.ScreenDismissed += (sender, e) => {
                    interstitialRequested = false;

                    // You need to explicitly Dispose GADInterstitial when you dont need it anymore
                    // to avoid crashes if pending request are in progress
                    adInterstitial.Dispose();
                    adInterstitial = null;
                };
            }

            interstitialRequested = true;
            adInterstitial.LoadRequest(GADRequest.Request);

            ShowInterstitial();
        }
コード例 #2
0
        public void Show(string adUnit)
        {
            _adInterstitial = new GADInterstitial(adUnit);
            var request = GADRequest.Request;

            _adInterstitial.AdReceived += (sender, args) =>
            {
                if (_adInterstitial.IsReady)
                {
                    var window = UIApplication.SharedApplication.KeyWindow;
                    var vc     = window.RootViewController;
                    while (vc.PresentedViewController != null)
                    {
                        vc = vc.PresentedViewController;
                    }
                    _adInterstitial.PresentFromRootViewController(vc);
                }
            };
            _adInterstitial.LoadRequest(request);
        }