Exemple #1
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 Zone GetZone(string zoneId)
        {
            string    zoneJson   = _pluginWrapper.CallStatic <string>("getZone", zoneId);
            Hashtable zoneValues = (AdColonyJson.Decode(zoneJson) as Hashtable);

            return(new Zone(zoneValues));
        }
Exemple #3
0
        public Zone GetZone(string zoneId)
        {
            string    zoneJson   = _AdcGetZone(zoneId);
            Hashtable zoneValues = (AdColonyJson.Decode(zoneJson) as Hashtable);

            return(new Zone(zoneValues));
        }
        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);
                }
            }
        }
        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);
            }
        }
        public void _OnAdColonyAdViewClicked(string paramJson)
        {
            Debug.Log("AdColony.Wrapper._OnAdColonyAdViewClicked called.");
            Hashtable values = (AdColonyJson.Decode(paramJson) as Hashtable);

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

            AdColonyAdView adColonyAdView = GetAdColonyAdViewFromHashtable(values);

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

            if (Ads.OnAdViewClicked != null)
            {
                if (adColonyAdView != null)
                {
                    Ads.OnAdViewClicked(adColonyAdView);
                }
                else
                {
                    Debug.LogError(Constants.AdsMessageErrorUnableToRebuildAd);
                }
            }
        }
        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);
            }
        }
        // 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();
        }
Exemple #9
0
        public void _OnIAPOpportunity(string paramJson)
        {
            Debug.Log("_OnIAPOpportunity called");
            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 = new InterstitialAd(valuesAd);

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

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

            if (Ads.OnAudioStopped != null)
            {
                Ads.OnAudioStopped(ad);
            }
        }
        public void LogEvent(string name, Hashtable data)
        {
            string json = "{}";

            if (data != null)
            {
                json = AdColonyJson.Encode(data);
            }
            _AdcLogEvent(name, json);
        }
        public void _OnLeftApplication(string paramJson)
        {
            Hashtable      values = (AdColonyJson.Decode(paramJson) as Hashtable);
            InterstitialAd ad     = GetAdFromHashtable(values);

            if (Ads.OnLeftApplication != null)
            {
                Ads.OnLeftApplication(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));
        }
Exemple #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 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);
            }
        }
Exemple #19
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 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);
        }
        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);
        }
Exemple #22
0
 public void LogEvent(string name, Hashtable data)
 {
     if (data != null)
     {
         string json = AdColonyJson.Encode(data);
         _pluginWrapper.CallStatic("logEvent", name, json);
     }
     else
     {
         _plugin.CallStatic("logEvent", name);
     }
 }
        public void PurchaseProductGoogle(string googleReceiptJson, string googleSignature, string purchaseLocale, long purchasePriceMicro, int inGameCurrencyQuantityForProduct)
        {
            Hashtable values = new Hashtable();

            values["googleReceiptJson"]  = googleReceiptJson;
            values["googleSignature"]    = googleSignature;
            values["purchaseLocale"]     = purchaseLocale;
            values["purchasePriceMicro"] = purchasePriceMicro;
            values["inGameCurrencyQuantityForProduct"] = inGameCurrencyQuantityForProduct;
            string json = AdColonyJson.Encode(values);

            _pluginWrapper.CallStatic("purchaseProductGoogle", json);
        }
        public void RequestInterstitialAd(string zoneId, AdOptions adOptions)
        {
            Hashtable values = new Hashtable();

            values["zone_id"] = zoneId;
            if (adOptions != null)
            {
                values["ad_options"] = adOptions.ToHashtable();
            }

            string json = AdColonyJson.Encode(values);

            _pluginWrapper.CallStatic("requestInterstitialAd", json);
        }
        public string toJsonString()
        {
            Hashtable data = new Hashtable();

            data.Add(Constants.ZoneIdentifierKey, Identifier);
            data.Add(Constants.ZoneTypeKey, Convert.ToInt32(Type).ToString());
            data.Add(Constants.ZoneEnabledKey, Enabled ? "1" : "0");
            data.Add(Constants.ZoneRewardedKey, Rewarded ? "1" : "0");
            data.Add(Constants.ZoneViewsPerRewardKey, ViewsPerReward.ToString());
            data.Add(Constants.ZoneViewsUntilRewardKey, ViewsUntilReward.ToString());
            data.Add(Constants.ZoneRewardAmountKey, RewardAmount.ToString());
            data.Add(Constants.ZoneRewardNameKey, RewardName);

            return(AdColonyJson.Encode(data));
        }
        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);
            }
        }
Exemple #27
0
        public void Configure(string appId, AppOptions appOptions, params string[] zoneIds)
        {
            Hashtable values = new Hashtable();

            values["app_id"]   = appId;
            values["zone_ids"] = new ArrayList(zoneIds);
            if (appOptions != null)
            {
                values["app_options"] = appOptions.ToHashtable();
            }

            string json = AdColonyJson.Encode(values);

            _pluginWrapper.CallStatic("configure", json);
        }
        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 RequestAdView(string zoneId, AdSize adSize, AdPosition adPosition, AdOptions adOptions)
        {
            Hashtable values = new Hashtable();

            values["zone_id"]     = zoneId;
            values["ad_size"]     = (Int32)adSize;
            values["ad_position"] = (Int32)adPosition;
            if (adOptions != null)
            {
                values["ad_options"] = adOptions.ToHashtable();
            }

            string json = AdColonyJson.Encode(values);

            _pluginWrapper.CallStatic("requestAdView", json);
        }
        public void Configure(string appId, AppOptions appOptions, params string[] zoneIds)
        {
            Hashtable values = new Hashtable();

            values["app_id"]   = appId;
            values["zone_ids"] = new ArrayList(zoneIds);
            if (appOptions == null)
            {
                appOptions = new AppOptions();
            }
            appOptions.SetOption("plugin_version", AdColony.Constants.AdapterVersion);
            values["app_options"] = appOptions.ToHashtable();

            string json = AdColonyJson.Encode(values);

            _pluginWrapper.CallStatic("configure", json);
        }