Esempio n. 1
0
    public void LoadIntersititialAd()
    {
        if (isInterstitialLoading)
        {
            return;
        }
        if (isInterstitialAdLoaded)
        {
            return;
        }

        isInterstitialLoading  = true;
        isInterstitialAdLoaded = false;

        StatusShow.instance.ShowAdStatus("Loading Interstitial Ad....");
        interstitialAd = new InterstitialAd(intersititialAdId);
        interstitialAd.Register(gameObject);

        interstitialAd.InterstitialAdDidLoad = delegate()
        {
            LoadingInterstitialAdSuccessful();
        };
        interstitialAd.InterstitialAdDidFailWithError = delegate(string error)
        {
            LoadingInterstitialAdFaild();
        };
        interstitialAd.InterstitialAdDidClose = delegate()
        {
            InterstitialAdClosed();
        };
        interstitialAd.LoadAd();
    }
Esempio n. 2
0
        protected override bool DoPreLoadAd()
        {
#if UNITY_IOS
            if (m_InterstitialAd != null)
            {
                return(false);
            }
#endif

            if (m_InterstitialAd == null)
            {
                m_InterstitialAd = new InterstitialAd(m_Config.unitID);
                m_InterstitialAd.Register(UIMgr.S.uiRoot.gameObject);
                m_InterstitialAd.InterstitialAdDidLoad            = HandleOnAdLoaded;
                m_InterstitialAd.InterstitialAdDidFailWithError  += HandleOnAdFailedToLoad;
                m_InterstitialAd.InterstitialAdWillLogImpression += HandleOnAdOpened;
                m_InterstitialAd.InterstitialAdDidClick          += HandleOnAdClick;
                m_InterstitialAd.InterstitialAdDidClose          += HandleOnAdClosed;
            }

            if (m_InterstitialAd.IsValid())
            {
                return(false);
            }

            m_InterstitialAd.LoadAd();

            return(true);
        }
    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();
    }
        /// <summary>
        /// Create new interstitial with specific id.
        /// </summary>
        protected virtual Interstitial CreateNewInterstitialAd(string interstitialId, AdPlacement placement)
        {
            if (string.IsNullOrEmpty(interstitialId))
            {
                return(null);
            }

            InterstitialAd newInterstitial = new InterstitialAd(interstitialId);

            SetupInterstitialAdEvents(newInterstitial, placement);

            newInterstitial.Register(mAdHandlerObject);

            return(new Interstitial(newInterstitial));
        }
Esempio n. 5
0
        protected override void OnSendRequest()
        {
            //CLog.Log(this, "Interstitial is loading");
            // 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(AdUnit.AdId);
            interstitialAd.Register(this.gameObject);

            // Set delegates to get notified on changes or when the user interacts with the ad.
            interstitialAd.InterstitialAdDidLoad           = HandleInterstitialDidLoad;
            interstitialAd.InterstitialAdDidFailWithError  = HandleInterstitialLoadFail;
            interstitialAd.InterstitialAdWillLogImpression = HandleInterstitialWillImpression;
            interstitialAd.InterstitialAdDidClick          = HandleInterstitialDidClick;
            interstitialAd.interstitialAdDidClose          = HandleInterstitialDidClose;
            // Initiate the request to load the ad.
            interstitialAd.LoadAd();
            //CLog.Log(this, "Sent request id " + AdUnit.AdId);
        }
        /// <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();
        }
Esempio n. 7
0
    // 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();
    }