public void ShowBanner(string placementId, AdsManager.InterstitialDelegate onAdLoaded = null)
    {
        if (string.IsNullOrEmpty(placementId))
        {
            onAdLoaded(false);
        }
        if (adView)
        {
            adView.Dispose();
        }

        // Create a banner's ad view with a unique placement ID (generate your own on the Facebook app settings).
        // Use different ID for each ad placement in your app.
        adView = new AdView(placementId, AdSize.BANNER_HEIGHT_50);

        adView.Register(gameObject);
        currentAdViewPosition = AdPosition.BOTTOM;

        adView.AdViewDidLoad = delegate()
        {
            adView.Show(currentAdViewPosition);
            onAdLoaded?.Invoke(true);
        };
        adView.AdViewDidFailWithError = delegate(string error)
        {
            LogError(error);
            onAdLoaded?.Invoke(false);
        };
        adView.LoadAd();
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Load a Facebook banner and ads the required listeners
        /// </summary>
        public void LoadBanner()
        {
            if (bannerAd)
            {
                bannerAd.Dispose();
            }
            AdSize bannerSize;

            if (bannerType == BannerType.Banner)
            {
                bannerSize = AdSize.BANNER_HEIGHT_50;
            }
            else
            {
                bannerSize = AdSize.BANNER_HEIGHT_50;
            }

            bannerAd = new AdView(bannerId, bannerSize);
            bannerAd.Register(gameObject);

            // Set delegates to get notified on changes or when the user interacts with the ad.
            bannerAd.AdViewDidLoad          += BannerLoadSucces;
            bannerAd.AdViewDidFailWithError  = BannerLoadFailed;
            bannerAd.AdViewWillLogImpression = BannerAdWillLogImpression;
            bannerAd.AdViewDidClick          = BannerAdDidClick;

            // Initiate a request to load an ad.
            bannerAd.LoadAd();
        }
        /// <summary>
        /// Create new banner ad.
        /// </summary>
        protected virtual BannerAd CreateNewBannerAd(string bannerId, AdSize adSize)
        {
            if (string.IsNullOrEmpty(bannerId))
            {
                return(null);
            }

            AdView newBanner = new AdView(bannerId, adSize);

            newBanner.Register(mAdHandlerObject);
            SetupBannerAdEvents(newBanner);

            return(new BannerAd(newBanner, adSize));
        }
    public void LoadBanner()
    {
        if (adView)
        {
            adView.Dispose();
        }

        statusLabel.text = "Loading Banner...";

        // Create a banner's ad view with a unique placement ID
        // (generate your own on the Facebook app settings).
        // Use different ID for each ad placement in your app.
        adView = new AdView("YOUR_PLACEMENT_ID", adSizeArray[currentAdSize]);


        adView.Register(gameObject);
        currentAdViewPosition = AdPosition.CUSTOM;

        // Set delegates to get notified on changes or when the user interacts
        // with the ad.
        adView.AdViewDidLoad = delegate()
        {
            currentScreenOrientation = Screen.orientation;
            adView.Show(100);
            string isAdValid = adView.IsValid() ? "valid" : "invalid";
            statusLabel.text = "Banner loaded and is " + isAdValid + ".";
            Debug.Log("Banner loaded");
        };
        adView.AdViewDidFailWithError = delegate(string error)
        {
            statusLabel.text = "Banner failed to load with error: " + error;
            Debug.Log("Banner failed to load with error: " + error);
        };
        adView.AdViewWillLogImpression = delegate()
        {
            statusLabel.text = "Banner logged impression.";
            Debug.Log("Banner logged impression.");
        };
        adView.AdViewDidClick = delegate()
        {
            statusLabel.text = "Banner clicked.";
            Debug.Log("Banner clicked.");
        };

        // Initiate a request to load an ad.
        adView.LoadAd();
    }
Ejemplo n.º 5
0
        private void LoadBanner()
        {
#if UNITY_ANDROID
            string adUnitId = GameConfig.Instance.FbAds.androidBanner.Trim();
#elif UNITY_IPHONE
            string adUnitID = GameConfig.Instance.FbAds.iOSBanner.Trim();
#endif
            if (_adView)
            {
                _adView.Dispose();
            }

            _adView = Testing
                ? new AdView("IMG_16_9_APP_INSTALL#457854978072123_469445200246434", AdSize.BANNER_HEIGHT_50)
                : new AdView(adUnitId, AdSize.BANNER_HEIGHT_50);

            _adView.Register(gameObject);

            _adView.AdViewDidFailWithError = (delegate(string error)
            {
                _bannerLoaded = false;
//            Debug.Log("Banner failed to load with error: " + error);
            });
            _adView.AdViewWillLogImpression = (delegate() { });
            _adView.AdViewDidClick          = (delegate() { });

            // Initiate a request to load an ad.
            _adView.LoadAd();
            // Set delegates to get notified on changes or when the user interacts with the ad.
            _adView.AdViewDidLoad = (delegate() // Banner loaded.
            {
                _bannerLoaded = true;
                _adView.Show(AdPosition.BOTTOM);
                AppsFlyerManager.Instance.TrackBannerFacebookView();
            });
            _adView.AdViewWillLogImpression = (delegate() // Banner logged impression
            {
            });
            _adView.AdViewDidClick = (delegate() // Banner clicked
            {
            });
        }
Ejemplo n.º 6
0
    public void LoadBannerAd()
    {
        StatusShow.instance.ShowAdStatus("Loading Banner...");
        if (bannerAdView)
        {
            bannerAdView.Dispose();
        }

        bannerAdView = new AdView(bannerAdId, bannerAdSize);
        bannerAdView.Register(gameObject);

        bannerAdView.AdViewDidLoad = delegate()
        {
            LoadingBannerAdSuccessful();
        };
        bannerAdView.AdViewDidFailWithError = delegate(string error)
        {
            LoadingBannerAdFaild();
        };

        bannerAdView.LoadAd();
    }
Ejemplo n.º 7
0
        protected override bool DoPreLoadAd()
        {
            if (string.IsNullOrEmpty(m_Config.unitID))
            {
                return(false);
            }

            if (m_BannerView == null)
            {
                m_BannerView = new AdView(m_Config.unitID, ConvertAdSize(m_AdInterface.adSize));

                m_BannerView.Register(UIMgr.S.uiRoot.gameObject);

                m_BannerView.AdViewDidLoad           += HandleOnAdLoaded;
                m_BannerView.AdViewDidFailWithError  += HandleOnAdFailedToLoad;
                m_BannerView.AdViewWillLogImpression += HandleOnAdOpened;

                //m_BannerView.DisableAutoRefresh();
            }

            return(true);
        }