public void _OnClicked(string paramJson)
        {
            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);

            if (values == null)
            {
                Debug.LogError("Unable to parse parameters in _OnClicked, " + (paramJson ?? "null"));
                return;
            }

            InterstitialAd ad = GetAdFromHashtable(values);

            if (ad == null)
            {
                Debug.LogError("Unable to create ad within _OnClicked, " + (paramJson ?? "null"));
                return;
            }

            if (Ads.OnClicked != null)
            {
                if (ad != null)
                {
                    Ads.OnClicked(ad);
                }
                else
                {
                    Debug.LogError(Constants.AdsMessageErrorUnableToRebuildAd);
                }
            }
        }
Esempio n. 2
0
        public Zone GetZone(string zoneId)
        {
            string    zoneJson   = _AdcGetZone(zoneId);
            Hashtable zoneValues = (AdColonyJson.Decode(zoneJson) as Hashtable);

            return(new Zone(zoneValues));
        }
        public Zone GetZone(string zoneId)
        {
            string    zoneJson   = _pluginWrapper.CallStatic <string>("getZone", zoneId);
            Hashtable zoneValues = (AdColonyJson.Decode(zoneJson) as Hashtable);

            return(new Zone(zoneValues));
        }
Esempio n. 4
0
        public void _OnCustomMessageReceived(string paramJson)
        {
            Debug.Log("_OnCustomMessageReceived called");

            string type    = null;
            string message = null;

            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);

            if (values != null)
            {
                if (values.ContainsKey(Constants.OnCustomMessageReceivedTypeKey))
                {
                    type = values[Constants.OnCustomMessageReceivedTypeKey] as string;
                }
                if (values.ContainsKey(Constants.OnCustomMessageReceivedMessageKey))
                {
                    message = values[Constants.OnCustomMessageReceivedMessageKey] as string;
                }
            }

            if (Ads.OnCustomMessageReceived != null)
            {
                Ads.OnCustomMessageReceived(type, message);
            }
        }
        public void _OnRequestInterstitialFailed(string paramJson)
        {
            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);

            if (values == null)
            {
                Debug.LogError("Unable to parse parameters in _OnRequestInterstitialFailed, " + (paramJson ?? "null"));
                return;
            }

            string zoneId = "";

            if (values != null && values.ContainsKey("zone_id"))
            {
                zoneId = values["zone_id"] as string;
            }

            if (Ads.OnRequestInterstitialFailed != null)
            {
                Ads.OnRequestInterstitialFailed();
            }
            if (Ads.OnRequestInterstitialFailedWithZone != null)
            {
                Ads.OnRequestInterstitialFailedWithZone(zoneId);
            }
        }
        // Main initialization method.  Based on result of initialization, certain events may be fired off.
        // This service uses the API from the main AdColony API, that must be set first
        public static void Configure(string initParams = null)
        {
            // Using SharedInstance to make sure the MonoBehaviour is instantiated
            if (SharedInstance._instance == null)
            {
                Debug.LogWarning(Constants.PubServicesMessageSdkUnavailable);
                return;
            }

            Debug.Log(Constants.PubServicesManagerName + " SDK init, initParams: " + AdColonyJson.Encode(initParams));

            Hashtable h = null;

            try {
                if (initParams != null)
                {
                    h = (Hashtable)AdColonyJson.Decode(initParams);
                }
            } catch {
            }

            SharedInstance._instance.Configure(h);
            _initialized = true;
            SharedInstance._instance.SetUnityInitialized();
        }
        public void _OnRewardGranted(string paramJson)
        {
            string zoneId    = null;
            bool   success   = false;
            string productId = null;
            int    amount    = 0;

            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);

            if (values != null)
            {
                if (values.ContainsKey(Constants.OnRewardGrantedZoneIdKey))
                {
                    zoneId = values[Constants.OnRewardGrantedZoneIdKey] as string;
                }
                if (values.ContainsKey(Constants.OnRewardGrantedSuccessKey))
                {
                    success = Convert.ToBoolean(Convert.ToInt32(values[Constants.OnRewardGrantedSuccessKey]));
                }
                if (values.ContainsKey(Constants.OnRewardGrantedNameKey))
                {
                    productId = values[Constants.OnRewardGrantedNameKey] as string;
                }
                if (values.ContainsKey(Constants.OnRewardGrantedAmountKey))
                {
                    amount = Convert.ToInt32(values[Constants.OnRewardGrantedAmountKey]);
                }
            }

            if (Ads.OnRewardGranted != null)
            {
                Ads.OnRewardGranted(zoneId, success, productId, amount);
            }
        }
        public void _OnURLOpened(string paramJson)
        {
            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);

            string    url       = "";
            Hashtable urlParams = null;
            bool      handled   = false;

            if (values.ContainsKey("url"))
            {
                url = values["url"] as string;
            }
            if (values.ContainsKey("url_params"))
            {
                urlParams = (AdColonyJson.Decode(values["url_params"] as string) as Hashtable);
            }
            if (values.ContainsKey("handled"))
            {
                handled = (bool)values["handled"];
            }

            if (PubServices.OnURLOpened != null)
            {
                PubServices.OnURLOpened(url, urlParams, handled);
            }
        }
        public void _OnCustomMessageReceived(string paramJson)
        {
            string type    = null;
            string message = null;

            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);

            if (values == null)
            {
                Debug.LogError("Unable to parse parameters in _OnCustomMessageReceived, " + (paramJson ?? "null"));
                return;
            }

            if (values != null)
            {
                if (values.ContainsKey(Constants.OnCustomMessageReceivedTypeKey))
                {
                    type = values[Constants.OnCustomMessageReceivedTypeKey] as string;
                }
                if (values.ContainsKey(Constants.OnCustomMessageReceivedMessageKey))
                {
                    message = values[Constants.OnCustomMessageReceivedMessageKey] as string;
                }
            }

            if (Ads.OnCustomMessageReceived != null)
            {
                Ads.OnCustomMessageReceived(type, message);
            }
        }
        //Start Native Banner Callbacks.
        //below methods called from native code for Banner Ad.
        public void _OnAdColonyAdViewLoaded(string paramJson)
        {
            Debug.Log("AdColony.Wrapper._OnAdColonyAdViewLoaded called.");
            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);

            if (values == null)
            {
                Debug.LogError("Unable to parse parameters in _OnAdColonyAdViewLoaded, " + (paramJson ?? "null"));
                return;
            }

            AdColonyAdView adColonyAdView = GetAdColonyAdViewFromHashtable(values);

            if (adColonyAdView == null)
            {
                Debug.LogError("Unable to create ad within _OnAdColonyAdViewLoaded, " + (paramJson ?? "null"));
                return;
            }

            if (Ads.OnAdViewLoaded != null)
            {
                if (adColonyAdView != null)
                {
                    Ads.OnAdViewLoaded(adColonyAdView);
                }
                else
                {
                    Debug.LogError(Constants.AdsMessageErrorUnableToRebuildAd);
                }
            }
        }
Esempio n. 11
0
        public void _OnIAPOpportunity(string paramJson)
        {
            Hashtable            values       = (AdColonyJson.Decode(paramJson) as Hashtable);
            Hashtable            valuesAd     = null;
            string               iapProductId = null;
            AdsIAPEngagementType engagement   = AdsIAPEngagementType.AdColonyIAPEngagementEndCard;

            if (values.ContainsKey(Constants.OnIAPOpportunityAdKey))
            {
                valuesAd = values[Constants.OnIAPOpportunityAdKey] as Hashtable;
            }
            if (values.ContainsKey(Constants.OnIAPOpportunityEngagementKey))
            {
                engagement = (AdsIAPEngagementType)Convert.ToInt32(values[Constants.OnIAPOpportunityEngagementKey]);
            }
            if (values.ContainsKey(Constants.OnIAPOpportunityIapProductIdKey))
            {
                iapProductId = values[Constants.OnIAPOpportunityIapProductIdKey] as string;
            }

            InterstitialAd ad = GetAdFromHashtable(valuesAd);

            if (Ads.OnIAPOpportunity != null)
            {
                Ads.OnIAPOpportunity(ad, iapProductId, engagement);
            }
        }
        public PubServicesVIPInformation GetVIPInformation()
        {
            string    vipInformationJson = _pluginWrapper.CallStatic <string>("getVIPInformation");
            Hashtable values             = (AdColonyJson.Decode(vipInformationJson) as Hashtable);
            PubServicesVIPInformation userInformation = new PubServicesVIPInformation(values);

            return(userInformation);
        }
Esempio n. 13
0
        public void _OnAudioStopped(string paramJson)
        {
            Hashtable      values = (AdColonyJson.Decode(paramJson) as Hashtable);
            InterstitialAd ad     = GetAdFromHashtable(values);

            if (Ads.OnAudioStopped != null)
            {
                Ads.OnAudioStopped(ad);
            }
        }
Esempio n. 14
0
        public void _OnLeftApplication(string paramJson)
        {
            Hashtable      values = (AdColonyJson.Decode(paramJson) as Hashtable);
            InterstitialAd ad     = GetAdFromHashtable(values);

            if (Ads.OnLeftApplication != null)
            {
                Ads.OnLeftApplication(ad);
            }
        }
Esempio n. 15
0
        public AppOptions GetAppOptions()
        {
            string    optionsJson   = _AdcGetAppOptions();
            Hashtable optionsValues = new Hashtable();

            if (optionsJson != null)
            {
                optionsValues = (AdColonyJson.Decode(optionsJson) as Hashtable);
            }
            return(new AppOptions(optionsValues));
        }
        public void _OnPushNotificationReceived(string paramJson)
        {
            UnityEngine.Debug.Log("_OnPushNotificationReceived: " + paramJson);
            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);

            AdColony.PubServicesPushNotification pushNotification = new PubServicesPushNotification(values);
            if (PubServices.OnPushNotificationReceived != null)
            {
                PubServices.OnPushNotificationReceived(pushNotification);
            }
        }
Esempio n. 17
0
        public void _OnAudioStopped(string paramJson)
        {
            Debug.Log("_OnAudioStopped called");
            Hashtable      values = (AdColonyJson.Decode(paramJson) as Hashtable);
            InterstitialAd ad     = new InterstitialAd(values);

            if (Ads.OnAudioStopped != null)
            {
                Ads.OnAudioStopped(ad);
            }
        }
        public AppOptions GetAppOptions()
        {
            string    appOptionsJson   = _pluginWrapper.CallStatic <string>("getAppOptions");
            Hashtable appOptionsValues = new Hashtable();

            if (appOptionsJson != null)
            {
                appOptionsValues = (AdColonyJson.Decode(appOptionsJson) as Hashtable);
            }
            return(new AppOptions(appOptionsValues));
        }
Esempio n. 19
0
        public void _OnExpiring(string paramJson)
        {
            Hashtable      values = (AdColonyJson.Decode(paramJson) as Hashtable);
            InterstitialAd ad     = GetAdFromHashtable(values);

            if (Ads.OnExpiring != null)
            {
                Ads.OnExpiring(ad);
            }

            _ads.Remove(ad.Id);
        }
        public Hashtable GetExperiments()
        {
            string experiments = _pluginWrapper.CallStatic <string>("getExperiments");

            try {
                Hashtable values = (AdColonyJson.Decode(experiments) as Hashtable);
                return(values);
            } catch (Exception e) {
                UnityEngine.Debug.LogError("PubServicesAndroid::GetExperiments() An error occurred: " + e);
            }
            return(null);
        }
Esempio n. 21
0
        public void _OnRequestInterstitialFailed(string paramJson)
        {
            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);
            string    zoneId = "";

            if (values != null && values.ContainsKey("zone_id"))
            {
                zoneId = values["zone_id"] as string;
            }

            if (Ads.OnRequestInterstitialFailedWithZone != null)
            {
                Ads.OnRequestInterstitialFailedWithZone(zoneId);
            }
        }
Esempio n. 22
0
        public void _OnConfigure(string paramJson)
        {
            List <Zone> zoneList     = new List <Zone>();
            ArrayList   zoneJsonList = (AdColonyJson.Decode(paramJson) as ArrayList);

            foreach (string zoneJson in zoneJsonList)
            {
                Hashtable zoneValues = (AdColonyJson.Decode(zoneJson) as Hashtable);
                zoneList.Add(new Zone(zoneValues));
            }

            if (Ads.OnConfigurationCompleted != null)
            {
                Ads.OnConfigurationCompleted(zoneList);
            }
        }
 public void _OnGrantDigitalProductItem(string digitalItemJson)
 {
     UnityEngine.Debug.Log("GrantDigitalProductItem(" + digitalItemJson + ")");
     try {
         Hashtable values = (AdColonyJson.Decode(digitalItemJson) as Hashtable);
         if (values != null)
         {
             PubServicesDigitalItem digitalItem = new PubServicesDigitalItem(values);
             if (digitalItem != null)
             {
                 if (PubServices.OnGrantDigitalProductItem != null)
                 {
                     PubServices.OnGrantDigitalProductItem(digitalItem);
                 }
             }
         }
     } catch (Exception e) {
         UnityEngine.Debug.Log("Exception caught in CanGrantDigitalProductItem, " + e);
     }
 }
        public void _OnIAPProductPurchaseFailed(string paramJson)
        {
            string productId = "";
            string error     = "";

            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);

            if (values.ContainsKey("product_id"))
            {
                productId = values["product_id"] as string;
            }
            if (values.ContainsKey("error"))
            {
                error = values["error"] as string;
            }

            if (PubServices.OnInAppPurchaseRewardFailed != null)
            {
                PubServices.OnInAppPurchaseRewardFailed(productId, error);
            }
        }
        // Multiple items returned as JSON string
        public void _OnIAPProductPurchased(string paramJson)
        {
            int    inGameCurrencyBonus = 0;
            string productId           = "";

            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);

            if (values.ContainsKey("product_id"))
            {
                productId = values["product_id"] as string;
            }
            if (values.ContainsKey("in_game_currency_bonus"))
            {
                inGameCurrencyBonus = Convert.ToInt32(values["in_game_currency_bonus"]);
            }

            if (PubServices.OnInAppPurchaseReward != null)
            {
                PubServices.OnInAppPurchaseReward(productId, inGameCurrencyBonus);
            }
        }
        public void _OnIAPOpportunity(string paramJson)
        {
            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);

            if (values == null)
            {
                Debug.LogError("Unable to parse parameters in _OnIAPOpportunity, " + (paramJson ?? "null"));
                return;
            }

            Hashtable            valuesAd     = null;
            string               iapProductId = null;
            AdsIAPEngagementType engagement   = AdsIAPEngagementType.AdColonyIAPEngagementEndCard;

            if (values.ContainsKey(Constants.OnIAPOpportunityAdKey))
            {
                valuesAd = (AdColonyJson.Decode(values[Constants.OnIAPOpportunityAdKey] as String)) as Hashtable;
            }
            if (values.ContainsKey(Constants.OnIAPOpportunityEngagementKey))
            {
                engagement = (AdsIAPEngagementType)Convert.ToInt32(values[Constants.OnIAPOpportunityEngagementKey]);
            }
            if (values.ContainsKey(Constants.OnIAPOpportunityIapProductIdKey))
            {
                iapProductId = values[Constants.OnIAPOpportunityIapProductIdKey] as string;
            }

            InterstitialAd ad = GetAdFromHashtable(valuesAd);

            if (ad == null)
            {
                Debug.LogError("Unable to create ad within _OnIAPOpportunity, " + (paramJson ?? "null"));
                return;
            }

            if (Ads.OnIAPOpportunity != null)
            {
                Ads.OnIAPOpportunity(ad, iapProductId, engagement);
            }
        }
        //below methods called from native code for Interstital Ad.
        public void _OnConfigure(string paramJson)
        {
            List <Zone> zoneList     = new List <Zone>();
            ArrayList   zoneJsonList = (AdColonyJson.Decode(paramJson) as ArrayList);

            if (zoneJsonList == null)
            {
                Debug.LogError("Unable to parse parameters in _OnConfigure, " + (paramJson ?? "null"));
                return;
            }

            foreach (string zoneJson in zoneJsonList)
            {
                Hashtable zoneValues = (AdColonyJson.Decode(zoneJson) as Hashtable);
                zoneList.Add(new Zone(zoneValues));
            }

            if (Ads.OnConfigurationCompleted != null)
            {
                Ads.OnConfigurationCompleted(zoneList);
            }
        }
        public Dictionary <string, long> GetStats()
        {
            Dictionary <string, long> stats = new Dictionary <string, long>();
            string    data   = _pluginWrapper.CallStatic <string>("getStats");
            ArrayList values = (AdColonyJson.Decode(data) as ArrayList);

            if (values != null)
            {
                foreach (Hashtable h in values)
                {
                    if (h.ContainsKey("name") && h.ContainsKey("value"))
                    {
                        stats.Add((string)h["name"], Int64.Parse(h["value"].ToString()));
                    }
                }
            }
            else
            {
                Debug.Log("Unable to decode stats: " + data);
            }

            return(stats);
        }
        public void _OnServiceAvailabilityChanged(string value)
        {
            UnityEngine.Debug.Log("_OnServiceAvailabilityChanged called");
            string error = "";
            PubServicesStatusType status = PubServicesStatusType.Unknown;

            Hashtable values = (AdColonyJson.Decode(value) as Hashtable);

            if (values.ContainsKey("error"))
            {
                error = values["error"] as string;
            }

            if (values.ContainsKey("status"))
            {
                int temp = Convert.ToInt32(values["status"]);
                status = (PubServicesStatusType)temp;
            }

            if (PubServices.OnServiceAvailabilityChanged != null)
            {
                PubServices.OnServiceAvailabilityChanged(status, error);
            }
        }