public void RequestInterstitialNoShow(string placementId, AdsManager.InterstitialDelegate onAdLoaded = null, bool showLoading = true) { if (string.IsNullOrEmpty(placementId)) { onAdLoaded(false); } if (interstitialAd != null) { interstitialAd.Dispose(); } interstitialAd = new InterstitialAd(placementId); interstitialAd.Register(gameObject); if (onAdLoaded != null) { interstitialDelegate = onAdLoaded; } interstitialAd.InterstitialAdDidLoad = InterstitialAdDidLoad; interstitialAd.InterstitialAdDidFailWithError = InterstitialAdDidFailWithError; interstitialAd.InterstitialAdWillLogImpression = InterstitialAdWillLogImpression; interstitialAd.InterstitialAdDidClick = InterstitialAdDidClick; interstitialAd.InterstitialAdDidClose = InterstitialAdDidClose; #if UNITY_ANDROID /* This callback will only be triggered if the Interstitial activity has * been destroyed without being properly closed. This can happen if an * app with launchMode:singleTask (such as a Unity game) goes to * background and is then relaunched by tapping the icon. */ interstitialAd.interstitialAdActivityDestroyed = InterstitialAdActivityDestroyed; #endif interstitialAd.LoadAd(); }
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; } }); } }
public override void destroyAd() { if (interstitialAd != null) { interstitialAd.Dispose(); } }
private void OnDestroy() { if (interstitialAd != null) { interstitialAd.Dispose(); } UnityEngine.Debug.Log("InterstitialAdTest was destroyed!"); }
void OnDestroy() { // Dispose of interstitial ad when the scene is destroyed if (interstitialAd != null) { interstitialAd.Dispose(); } Debug.Log("InterstitialAdTest was destroyed!"); }
void ShowInterstitialAd(UIAlertAction obj) { interstitialAd?.Dispose(); interstitialAd = null; interstitialAd = new InterstitialAd(AdPlacementIds.Interstitial) { Delegate = this }; interstitialAd.LoadAd(); }
/// <summary> /// Loads a Facebook interstitial and ads the required listeners /// </summary> private void LoadInterstitial() { if (interstitialAd != null) { interstitialAd.Dispose(); } interstitialIsLoaded = false; interstitialAd = new InterstitialAd(interstitialId); interstitialAd.Register(gameObject); interstitialAd.InterstitialAdDidLoad += InterstitialLoaded; interstitialAd.InterstitialAdDidFailWithError += InterstitialFailed; interstitialAd.InterstitialAdWillLogImpression += InterstitialAdWillLogImpression; interstitialAd.InterstitialAdDidClick += InterstitialAdDidClick; interstitialAd.InterstitialAdDidClose += InterstitialClosed; #if UNITY_ANDROID /* * Only relevant to Android. * This callback will only be triggered if the Interstitial activity has * been destroyed without being properly closed. This can happen if an * app with launchMode:singleTask (such as a Unity game) goes to * background and is then relaunched by tapping the icon. */ interstitialAd.interstitialAdActivityDestroyed = delegate() { if (!interstitialDidClose) { if (debug) { Debug.Log(this + " " + "Interstitial activity destroyed without being closed first."); ScreenWriter.Write(this + " " + "Interstitial activity destroyed without being closed first."); } InterstitialClosed(); } }; #endif interstitialAd.LoadAd(); }
private void InterstitialAdClosed() { isInterstitialAdLoaded = false; isInterstitialLoading = false; if (interstitialAd != null) { interstitialAd.Dispose(); } StatusShow.instance.ShowAdStatus("Interstitial Ad Closed"); LoadIntersititialAd(); }
protected override void DoCleanAd() { if (m_InterstitialAd == null) { return; } //#if UNITY_IOS m_InterstitialAd.Dispose(); m_InterstitialAd = null; //#endif }
protected override void OnDisposeAd() { if (interstitialAd != null) { interstitialAd.InterstitialAdDidLoad = null; interstitialAd.InterstitialAdDidFailWithError = null; interstitialAd.InterstitialAdWillLogImpression = null; interstitialAd.InterstitialAdDidClick = null; interstitialAd.InterstitialAdWillClose = null; interstitialAd.Dispose(); interstitialAd = null; } }
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); } }
public void InitAd() { _interstitialAd = new InterstitialAd(CrossCurrentActivity.Current.Activity); // _interstitialAd.AdUnitId = App.InterstitialAndroidId; var adListener = new AdMobAdListener(); adListener.AdClosed += () => { AdClosed?.Invoke(); _interstitialAd.Dispose(); _interstitialAd = null; }; adListener.AdLoaded += () => { AdReady?.Invoke(); }; _interstitialAd.AdListener = adListener; }
// Load button public void LoadInterstitial() { statusLabel.text = "Loading interstitial ad..."; // Create the interstitial unit with a placement ID (generate your own on the Facebook app settings). // Use different ID for each ad placement in your app. interstitialAd = new InterstitialAd("YOUR_PLACEMENT_ID"); interstitialAd.Register(gameObject); // Set delegates to get notified on changes or when the user interacts with the ad. interstitialAd.InterstitialAdDidLoad = delegate() { Debug.Log("Interstitial ad loaded."); isLoaded = true; didClose = false; string isAdValid = interstitialAd.IsValid() ? "valid" : "invalid"; statusLabel.text = "Ad loaded and is " + isAdValid + ". Click show to present!"; }; interstitialAd.InterstitialAdDidFailWithError = delegate(string error) { Debug.Log("Interstitial ad failed to load with error: " + error); statusLabel.text = "Interstitial ad failed to load. Check console for details."; }; interstitialAd.InterstitialAdWillLogImpression = delegate() { Debug.Log("Interstitial ad logged impression."); }; interstitialAd.InterstitialAdDidClick = delegate() { Debug.Log("Interstitial ad clicked."); }; interstitialAd.InterstitialAdDidClose = delegate() { Debug.Log("Interstitial ad did close."); didClose = true; if (interstitialAd != null) { interstitialAd.Dispose(); } }; #if UNITY_ANDROID /* * Only relevant to Android. * This callback will only be triggered if the Interstitial activity has * been destroyed without being properly closed. This can happen if an * app with launchMode:singleTask (such as a Unity game) goes to * background and is then relaunched by tapping the icon. */ interstitialAd.interstitialAdActivityDestroyed = delegate() { if (!didClose) { Debug.Log("Interstitial activity destroyed without being closed first."); Debug.Log("Game should resume."); } }; #endif // Initiate the request to load the ad. interstitialAd.LoadAd(); }