Beispiel #1
0
        public static void addBanner(BannerType bannerType, BannerPosition position)
        {
            int pos = 1;
            int type = 1;
            // Select position
            switch(position){
                case BannerPosition.BOTTOM:
                    pos = 1;
                    break;
                case BannerPosition.TOP:
                    pos = 2;
                    break;
            }
            AndroidJavaObject objPosition = new AndroidJavaObject("java.lang.Integer", pos);

            // Select type
            switch(bannerType){
                case BannerType.AUTOMATIC:
                    type = 1;
                    break;
                case BannerType.STANDARD:
                    type = 2;
                    break;
                case BannerType.THREED:
                    type = 3;
                    break;
            }
            AndroidJavaObject objType = new AndroidJavaObject("java.lang.Integer", type);

            getWrapper();
            wrapper.Call("addBanner", new []{ objType, objPosition });
        }
Beispiel #2
0
    private static void CreateStubBanner(string adUnitIdentifier, BannerPosition bannerPosition)
    {
#if UNITY_EDITOR
        // Only support BottomCenter and TopCenter for now
        var bannerPrefabName = bannerPosition == BannerPosition.BottomCenter ? "BannerBottom" : "BannerTop";
        var prefabPath       = MaxSdkUtils.GetAssetPathForExportPath("MaxSdk/Prefabs/" + bannerPrefabName + ".prefab");
        var bannerPrefab     = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath);
        var stubBanner       = Object.Instantiate(bannerPrefab, Vector3.zero, Quaternion.identity);
        stubBanner.SetActive(false); // Hidden by default
        Object.DontDestroyOnLoad(stubBanner);

        var bannerText = stubBanner.GetComponentInChildren <Text>();
        bannerText.text += ":\n" + adUnitIdentifier;

        StubBanners.Add(adUnitIdentifier, stubBanner);
#endif
    }
Beispiel #3
0
    IEnumerator ShowBannerWhenReady(string placementId, BannerPosition bannerPosition, AdsManager.InterstitialDelegate onAdLoaded = null)
    {
        Advertisement.Banner.SetPosition(bannerPosition);

        BannerLoadOptions options = new BannerLoadOptions {
            loadCallback = OnLoadBannerSuccess, errorCallback = OnLoadBannerFail
        };

        Advertisement.Banner.Load(placementId, options);

        float timeoutTime = 5f, retryInterval = 0.2f;
        WaitForSecondsRealtime delay = new WaitForSecondsRealtime(retryInterval);
        int tryTimes = 0;

        while (!bannerLoadSuccess.HasValue && tryTimes < timeoutTime / retryInterval)
        {
            yield return(delay);

            tryTimes++;
        }

        if (!bannerLoadSuccess.HasValue)
        {
            LogEvent("LoadBannerTimeout", "", "");
            bannerLoadSuccess = false;
        }
        onAdLoaded?.Invoke(bannerLoadSuccess.Value);

        bool           adReady = Advertisement.IsReady(placementId);
        PlacementState adState = Advertisement.GetPlacementState(placementId);

        if (bannerLoadSuccess.Value)
        {
            Debug.Log($"Unity banner showing. State: {Advertisement.GetPlacementState(placementId)}, ready {adReady}");
            Advertisement.Banner.Show(placementId);
        }
        else
        {
            Debug.Log($"Unity banner show failed. State: {Advertisement.GetPlacementState(placementId)}, ready {adReady}");
        }

        /*if (adReady) //show banner regardless of load success or not since Unity Ads is the only ads
         *  Advertisement.Banner.Show(placementId);*/
        bannerLoadSuccess = null;
    }
Beispiel #4
0
        private static AndroidJavaObject getBannerPositionObject(BannerPosition bannerPosition)
        {
            int pos = 1;

            switch (bannerPosition)
            {
            case BannerPosition.BOTTOM:
                pos = 1;
                break;

            case BannerPosition.TOP:
                pos = 2;
                break;
            }
            AndroidJavaObject objPosition = new AndroidJavaObject("java.lang.Integer", pos);

            return(objPosition);
        }
        public async Task <List <Banner> > LoadBanners(string categoryId = null, BannerPosition position = BannerPosition.Bottom | BannerPosition.Top)
        {
            await Task.Delay(500);

            return(string.IsNullOrEmpty(categoryId) ?
                   new List <Banner>
            {
                new Banner {
                    Id = "1", ImageUrl = "https://image.shutterstock.com/z/stock-photo-retro-toned-poppy-flowers-at-sunrise-shallow-depth-of-field-ratio-304321280.jpg", Position = BannerPosition.Top, Deeplink = "category://categoryId=3&navigationType=2"
                },
                new Banner {
                    Id = "1", ImageUrl = "https://image.shutterstock.com/z/stock-photo-vintage-toned-poppy-flowers-at-sunrise-shallow-depth-of-field-ratio-304321328.jpg", Position = BannerPosition.Top, Deeplink = "products://categoryId=30&navigationType=1"
                },
                new Banner {
                    Id = "1", ImageUrl = "https://image.shutterstock.com/z/stock-photo-white-ornithogalum-grass-lily-flowers-with-blue-leaves-aspect-ratio-260556620.jpg", Position = BannerPosition.Bottom, Deeplink = "product://productId=1&navigationType=1"
                }
            } :
                   new List <Banner>());
        }
Beispiel #6
0
    public void ShowBanner(BannerPosition position = BannerPosition.Bottom)
    {
        switch (position)
        {
        case Solitaire.BannerPosition.BottomLeft:
        {
            m_BannerView.SetPosition(AdPosition.BottomLeft);
            break;
        }

        case Solitaire.BannerPosition.BottomRight:
        {
            m_BannerView.SetPosition(AdPosition.BottomRight);
            break;
        }

        case Solitaire.BannerPosition.Top:
        {
            m_BannerView.SetPosition(AdPosition.Top);
            break;
        }

        case Solitaire.BannerPosition.TopLeft:
        {
            m_BannerView.SetPosition(AdPosition.TopLeft);
            break;
        }

        case Solitaire.BannerPosition.TopRight:
        {
            m_BannerView.SetPosition(AdPosition.TopRight);
            break;
        }

        default:
        {
            m_BannerView.SetPosition(AdPosition.Bottom);
            break;
        }
        }
        m_BannerView.Show();
    }
Beispiel #7
0
        public static void removeBanner(BannerPosition position)
        {
            int pos = 1;

            // Select position
            switch (position)
            {
            case BannerPosition.BOTTOM:
                pos = 1;
                break;

            case BannerPosition.TOP:
                pos = 2;
                break;
            }
            AndroidJavaObject objPosition = new AndroidJavaObject("java.lang.Integer", pos);

            getWrapper();
            wrapper.Call("removeBanner", objPosition);
        }
Beispiel #8
0
        public static void addBanner(BannerType bannerType, BannerPosition position)
        {
            int pos  = 1;
            int type = 1;

            // Select position
            switch (position)
            {
            case BannerPosition.BOTTOM:
                pos = 1;
                break;

            case BannerPosition.TOP:
                pos = 2;
                break;
            }
            AndroidJavaObject objPosition = new AndroidJavaObject("java.lang.Integer", pos);


            // Select type
            switch (bannerType)
            {
            case BannerType.AUTOMATIC:
                type = 1;
                break;

            case BannerType.STANDARD:
                type = 2;
                break;

            case BannerType.THREED:
                type = 3;
                break;
            }
            AndroidJavaObject objType = new AndroidJavaObject("java.lang.Integer", type);


            getWrapper();
            wrapper.Call("addBanner", new [] { objType, objPosition });
        }
        private int AddData()
        {
            string UserId          = Session["UserId"].ToString();
            int    parentid        = Convert.ToInt32(ddlTreeNode.SelectedValue);
            string banner_position = txtBannerPosition.Text;
            string description     = txtDescription.Text;
            bool   bStatus         = ChkBoxStatus.Checked;
            string status          = string.Empty;

            if (bStatus == true)
            {
                status = "1";
            }
            else
            {
                status = "0";
            }
            BannerPosition banner_position_obj = new BannerPosition();
            int            i = banner_position_obj.Insert(parentid, banner_position, description, status);

            return(i);
        }
Beispiel #10
0
    public void ShowBannerAd(BannerPosition bannerPosition)
    {
        if (!Advertisement.isInitialized)
        {
            InitializeAds();
        }

        if (!Advertisement.Banner.isLoaded)
        {
            BannerLoadOptions loadOptions = new BannerLoadOptions
            {
                loadCallback  = OnBannerLoaded,
                errorCallback = OnBannerError
            };

            Advertisement.Banner.SetPosition(bannerPosition);
            Advertisement.Banner.Load(BannerAd, loadOptions);
        }
        else
        {
            OnBannerLoaded();
        }
    }
        AdPosition AdapterBannerPosition(BannerPosition position)
        {
            switch (position)
            {
            case BannerPosition.Top:
                return(AdPosition.Top);

            case BannerPosition.Bottom:
                return(AdPosition.Bottom);

            case BannerPosition.TopLeft:
                return(AdPosition.TopLeft);

            case BannerPosition.TopRight:
                return(AdPosition.TopRight);

            case BannerPosition.BottomLeft:
                return(AdPosition.BottomRight);

            case BannerPosition.Center:
                return(AdPosition.Center);
            }
            return(AdPosition.Bottom);
        }
        public MockBannerAd CreateBannerMockAdInstance(BannerSize bannerSize, BannerPosition bannerPosition)
        {
            MockBannerAd mockAdInstance;
            MockBannerAd mockAdPrefab;

            var mockAdPrefabName = isPortrait() ? "Prefabs/MockAd_banner_portrait" : "Prefabs/MockAd_banner_landscape";

            mockAdPrefab = Resources.Load <MockBannerAd>(mockAdPrefabName);

            mockAdInstance = GameObject.Instantiate(mockAdPrefab);

            var bannerCanvas = (RectTransform)mockAdInstance.transform.Find("Canvas/BgColor");

            // Remove title from Rectangle banners because it's too small to show it.
            if (bannerSize == BannerSize.Rectangle)
            {
                var textChild = bannerCanvas.transform.Find("Title");
                textChild.parent = null;
            }

            ResizeAndPositionBannerCanvas(bannerSize, bannerPosition, bannerCanvas);

            return(mockAdInstance);
        }
        MaxSdkBase.BannerPosition AdapterBannerPosition(BannerPosition position)
        {
            switch (position)
            {
            case BannerPosition.Top:
                return(MaxSdkBase.BannerPosition.TopCenter);

            case BannerPosition.Bottom:
                return(MaxSdkBase.BannerPosition.BottomCenter);

            case BannerPosition.TopLeft:
                return(MaxSdkBase.BannerPosition.TopLeft);

            case BannerPosition.TopRight:
                return(MaxSdkBase.BannerPosition.TopRight);

            case BannerPosition.BottomLeft:
                return(MaxSdkBase.BannerPosition.BottomLeft);

            case BannerPosition.BottomRight:
                return(MaxSdkBase.BannerPosition.BottomRight);
            }
            return(MaxSdkBase.BannerPosition.BottomCenter);
        }
Beispiel #14
0
        public static bool checkIfBannerExists(BannerPosition bannerPosition)
        {
            AndroidJavaObject objPosition = getBannerPositionObject(bannerPosition);

            return(wrapper.Call <bool> ("checkIfBannerExists", objPosition));
        }
Beispiel #15
0
        public static void removeBanner(BannerPosition position)
        {
            int pos = 1;
            // Select position
            switch(position){
            case BannerPosition.BOTTOM:
                pos = 1;
                break;
            case BannerPosition.TOP:
                pos = 2;
                break;
            }
            AndroidJavaObject objPosition = new AndroidJavaObject("java.lang.Integer", pos);

            getWrapper();
            wrapper.Call("removeBanner", objPosition);
        }
Beispiel #16
0
 public abstract void ShowInPosition(BannerPosition position = BannerPosition.Bottom, BannerType type = BannerType.Regular);
Beispiel #17
0
 public abstract bool IsShownInPosition(BannerPosition position);
		public static void addBanner(BannerType bannerType, BannerPosition bannerPosition) {
			init();
			AndroidJavaObject objPosition = getBannerPositionObject (bannerPosition);
			AndroidJavaObject objType = getBannerTypeObject (bannerType);
			wrapper.Call("addBanner", new []{ objType, objPosition });
		}
 /// <summary>
 /// Updates the position of the banner to the new position provided.
 /// </summary>
 /// <param name="adUnitIdentifier">The ad unit identifier of the banner for which to update the position</param>
 /// <param name="bannerPosition">A new position for the banner</param>
 public static void UpdateBannerPosition(string adUnitIdentifier, BannerPosition bannerPosition)
 {
     Debug.Log("[AppLovin MAX] Updating banner position to '" + bannerPosition + "' for ad unit id '" + adUnitIdentifier + "'");
 }
Beispiel #20
0
        public async Task <List <BannerViewModel> > GetBanners(BannerPosition position)
        {
            var banner = await _bannerRepository.ListAsync(new BannerPublishedSpecification(position));

            return(BannerViewModel.GetList(banner.OrderBy(m => m.DisplayOrder)));
        }
Beispiel #21
0
 /// <summary>
 /// Displays a banner ad.
 ///
 /// If the display was successful, the event `BannerCompletedDisplayedEvent` will be called.
 /// Otherwise, the event `BannerFailedDisplayedEvent` will be called.
 /// </summary>
 /// <param name="tag">The game tag from where the ad will be displayed (like menu or store).</param>
 /// <param name="bannerPosition">The bannerPosition where the ad will be displayed.</param>
 public void ShowBanner(string tag, BannerPosition bannerPosition)
 {
     ShowBanner(tag, _defaultBannerSize, bannerPosition);
 }
		public static bool checkIfBannerExists(BannerPosition bannerPosition) {
			AndroidJavaObject objPosition = getBannerPositionObject (bannerPosition);
			return wrapper.Call<bool> ("checkIfBannerExists", objPosition);
		}
        private async Task <ObservableCollection <IBannerItemVM> > LoadBannersFor(string categoryId, BannerPosition position)
        {
            ObservableCollection <IBannerItemVM> dataSource = null;

            try
            {
                var banners = await BannersService.LoadBanners(categoryId, position) ?? new List <Banner>();

                dataSource = new ObservableCollection <IBannerItemVM>(banners.Select(c => SetupItem(c)));
            }
            catch (ConnectionException ex)
            {
                OnConnectionException(ex);
            }
            catch (Exception ex)
            {
                OnException(ex);
            }

            return(dataSource);
        }
 public void Initialize(string bAdUnit, BannerPosition bannerPos, string fsAdUnit, string rewardAdUnit)
 {
     MoPubAndroid.EnableLocationSupport(true);
     MoPubManager.OnAdLoadedEvent                        += this.onAdLoadedEvent;
     MoPubManager.OnAdFailedEvent                        += this.onAdFailedEvent;
     MoPubManager.OnAdClickedEvent                       += this.onAdClickedEvent;
     MoPubManager.OnAdExpandedEvent                      += this.onAdExpandedEvent;
     MoPubManager.OnAdCollapsedEvent                     += this.onAdCollapsedEvent;
     MoPubManager.OnInterstitialLoadedEvent              += this.onInterstitialLoadedEvent;
     MoPubManager.OnInterstitialFailedEvent              += this.onInterstitialFailedEvent;
     MoPubManager.OnInterstitialShownEvent               += this.onInterstitialShownEvent;
     MoPubManager.OnInterstitialClickedEvent             += this.onInterstitialClickedEvent;
     MoPubManager.OnInterstitialDismissedEvent           += this.onInterstitialDismissedEvent;
     MoPubManager.OnInterstitialExpiredEvent             += this.onInterstitialExpiredEvent;
     MoPubManager.OnRewardedVideoLoadedEvent             += this.onRewardedVideoLoadedEvent;
     MoPubManager.OnRewardedVideoFailedEvent             += this.onRewardedVideoFailedEvent;
     MoPubManager.OnRewardedVideoExpiredEvent            += this.onRewardedVideoExpiredEvent;
     MoPubManager.OnRewardedVideoShownEvent              += this.onRewardedVideoShownEvent;
     MoPubManager.OnRewardedVideoClickedEvent            += this.onRewardedVideoClickedEvent;
     MoPubManager.OnRewardedVideoFailedToPlayEvent       += this.onRewardedVideoFailedToPlayEvent;
     MoPubManager.OnRewardedVideoReceivedRewardEvent     += this.onRewardedVideoReceivedRewardEvent;
     MoPubManager.OnRewardedVideoClosedEvent             += this.onRewardedVideoClosedEvent;
     MoPubManager.OnRewardedVideoLeavingApplicationEvent += this.onRewardedVideoLeavingApplicationEvent;
     if (!string.IsNullOrEmpty(bAdUnit))
     {
         try
         {
             this.bannerAdUnit   = bAdUnit;
             this.bannerEnabled  = true;
             this.bannerPosition = ((bannerPos != BannerPosition.Bottom) ? MoPubBase.AdPosition.TopCenter : MoPubBase.AdPosition.BottomCenter);
             this.InternalInit(this.bannerAdUnit);
             MoPubAndroid.LoadBannerPluginsForAdUnits(new string[]
             {
                 this.bannerAdUnit
             });
         }
         catch (Exception ex)
         {
             this.bannerEnabled = false;
             FMLogger.vAds("failed to init mopab banner. error: " + ex.Message);
         }
     }
     if (!string.IsNullOrEmpty(fsAdUnit))
     {
         try
         {
             this.interstitialAdUnit = fsAdUnit;
             this.fsEnabled          = true;
             this.InternalInit(this.interstitialAdUnit);
             MoPubAndroid.LoadInterstitialPluginsForAdUnits(new string[]
             {
                 this.interstitialAdUnit
             });
         }
         catch (Exception ex2)
         {
             this.fsEnabled = false;
             FMLogger.vAds("failed to init mopab interstitial. error: " + ex2.Message);
         }
     }
     if (!string.IsNullOrEmpty(rewardAdUnit))
     {
         try
         {
             this.rewardUnit      = rewardAdUnit;
             this.rewardedEnabled = true;
             this.InternalInit(this.rewardUnit);
             MoPubAndroid.LoadRewardedVideoPluginsForAdUnits(new string[]
             {
                 this.rewardUnit
             });
         }
         catch (Exception ex3)
         {
             this.rewardUnit      = null;
             this.rewardedEnabled = false;
             FMLogger.Log("failed to init rewarded. error: " + ex3.Message);
         }
     }
     if (this.bannerEnabled || this.fsEnabled || this.rewardedEnabled)
     {
         ApplovinHelper.InitializeSdk();
     }
     this.RequestBanner();
     this.RequestInterstitial();
 }
Beispiel #25
0
 /// <summary>
 /// Displays a banner ad.
 ///
 /// If the display was successful, the event `BannerCompletedDisplayedEvent` will be called.
 /// Otherwise, the event `BannerFailedDisplayedEvent` will be called.
 /// </summary>
 /// <param name="bannerSize">The bannerSize of the Ad.</param>
 /// <param name="bannerPosition">The bannerPosition where the ad will be displayed.</param>
 public void ShowBanner(BannerSize bannerSize, BannerPosition bannerPosition)
 {
     ShowBanner(DEFAULT_TAG, bannerSize, bannerPosition);
 }
		public static void removeBanner(BannerPosition bannerPosition) {
			init();
			AndroidJavaObject objPosition = getBannerPositionObject(bannerPosition);
			wrapper.Call("removeBanner", objPosition);
		}
Beispiel #27
0
 // Change the BannerView position.
 public void SetPosition(BannerPosition position)
 {
     bannerView.Call("setPosition", (int)position);
 }
Beispiel #28
0
 /// <summary>
 /// <para>Sets the position of the banner ad, using the <a href="../api/UnityEngine.Advertisements.BannerPosition.html"><c>BannerPosition</c></a> enum.</para>
 /// <para>Banner position defaults to <c>BannerPosition.BOTTOM_CENTER</c>.</para>
 /// </summary>
 /// <param name="position">An enum representing the on-screen anchor position of the banner ad.</param>
 public void SetPosition(BannerPosition position)
 {
     bannerPosition = position;
 }
 public void ShowBanner(BannerPosition position, BannerType bannerType, UnityAction <bool, BannerPosition, BannerType> DisplayResult)
 {
 }
Beispiel #30
0
 /// <summary>
 /// <para>Sets the position of the banner ad, using the <a href="../api/UnityEngine.Advertisements.BannerPosition.html"><c>BannerPosition</c></a> enum.</para>
 /// <para>Banner position defaults to <c>BannerPosition.BOTTOM_CENTER</c>.</para>
 /// </summary>
 /// <param name="position">An enum representing the on-screen anchor position of the banner ad.</param>
 public static void SetPosition(BannerPosition position)
 {
     s_Platform.Banner.SetPosition(position);
 }
Beispiel #31
0
 /// <summary>
 /// Displays a banner ad.
 ///
 /// If the display was successful, the event `BannerCompletedDisplayedEvent` will be called.
 /// Otherwise, the event `BannerFailedDisplayedEvent` will be called.
 /// </summary>
 /// <param name="bannerPosition">The bannerPosition where the ad will be displayed.</param>
 public void ShowBanner(BannerPosition bannerPosition)
 {
     ShowBanner(DEFAULT_TAG, _defaultBannerSize, bannerPosition);
 }
		private static AndroidJavaObject getBannerPositionObject(BannerPosition bannerPosition) {
			int pos = 1;
			switch(bannerPosition) {
			case BannerPosition.BOTTOM:
				pos = 1;
				break;
			case BannerPosition.TOP:
				pos = 2;
				break;
			}
			AndroidJavaObject objPosition = new AndroidJavaObject("java.lang.Integer", pos);
			return objPosition;
		}
 public void ShowBanner(string tag, BannerSize bannerSize, BannerPosition bannerPosition)
 {
     SMAdsShowBanner(tag, bannerSize.Width, bannerSize.Height, bannerPosition.ToSnakeCaseString());
 }
Beispiel #34
0
 public static void setBannerPosition(BannerPosition bannerPosition)
 {
     _setBannerPosition(getStringFromBannerPosition(bannerPosition));
 }
Beispiel #35
0
 public static void Show(BannerPosition pos)
 {
     Advertisement.Banner.SetPosition(pos);
     Advertisement.Banner.Show(placementId: "banner");
 }
Beispiel #36
0
 public void SetPosition(BannerPosition position)
 {
 }