void AddToView()
        {
            if (interstitialRequested)
            {
                return;
            }

            if (adInterstitial == null)
            {
                InterstitialAd.Load(intersitialId, Request.GetDefaultRequest(), (ad, err) => {
                    if (ad != null)
                    {
                        adInterstitial = ad;

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

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

                        adInterstitial.Present(navController);
                    }
                    else
                    {
                        interstitialRequested = false;
                    }
                });
            }
        }
Esempio n. 2
0
        void AddToView()
        {
            if (adInterstitial?.CanPresent(NavigationController, out _) == true)
            {
                adInterstitial.DismissedContent += (sender, args) => {
                    // Interstitial is a one time use object. That means once an interstitial is shown, HasBeenUsed
                    // returns true and the interstitial can't be used to load another ad.
                    // To request another interstitial, you'll need to create a new Interstitial object.
                    adInterstitial.Dispose();
                    adInterstitial = null;
                    CreateAndRequestInterstitial();
                };

                adInterstitial.Present(NavigationController);
            }
        }