예제 #1
0
        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);
        }