Exemple #1
0
        private void FinishSwrveSDKInit()
        {
            SwrveComponent.Instance.Init(int.Parse(this.AnalyticsId), this.AnalyticsKey);
            SwrveConfig config = SwrveComponent.Instance.Config;

            if (config.AndroidPushProvider == AndroidPushProvider.GOOGLE_GCM && config.PushNotificationEnabled && !string.IsNullOrEmpty(config.GCMSenderId))
            {
                SwrveManagerUtils.RegisterGCMDevice(SwrveComponent.Instance.name, config.GCMSenderId, config.GCMPushNotificationTitle, config.GCMPushNotificationIconId, config.GCMPushNotificationMaterialIconId, config.GCMPushNotificationLargeIconId, config.GCMPushNotificationAccentColor, config.GCMSenderId.ToLower() + "Group");
            }
            Dictionary <string, string> deviceInfo = SwrveComponent.Instance.SDK.GetDeviceInfo();
            string text   = deviceInfo["swrve.device_name"];
            string value  = deviceInfo["swrve.os"];
            string value2 = deviceInfo["swrve.device_dpi"];
            string value3 = deviceInfo["swrve.device_width"];
            string value4 = deviceInfo["swrve.device_height"];
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Add("device_name", text);
            dictionary.Add("os", value);
            dictionary.Add("device_dpi", value2);
            dictionary.Add("device_width", value3);
            dictionary.Add("device_height", value4);
            if (!string.IsNullOrEmpty(SwrveComponent.Instance.Config.UserId))
            {
                dictionary.Add("swrve_user_id", SwrveComponent.Instance.Config.UserId);
            }
            else
            {
                SwrveManager.Log("### !!! unable to add userId to the userProps");
            }
            dictionary.Add("jailbroken.is_jailbroken", SwrveManagerUtils.GetIsJailBroken());
            dictionary.Add("lat.is_lat", SwrveManagerUtils.GetIsLat().ToString());
            string text2 = string.Empty;

            if (Application.platform == RuntimePlatform.Android)
            {
                text2 = "gida";
            }
            else if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                text2 = "idfa";
            }
            if (SwrveManagerUtils.IsAndiAvailable() && SwrveManagerUtils.IsAndiInitialized())
            {
                string text3 = (string)SwrveManagerUtils.ANDIType.GetMethod("GetAndiu").Invoke(null, null);
                SwrveManager.Log("### Let's send Swrve the andiu: " + text3);
                dictionary.Add("andiu", text3);
            }
            string text4 = SwrveManagerUtils.AESEncrypt(text, SwrveManagerUtils.GetAdvertiserID());

            SwrveManager.Log("### encryptedAdvertiserId: " + text4);
            if (!string.IsNullOrEmpty(text2))
            {
                dictionary.Add(text2, text4);
            }
            string rSAEncryptedKey = SwrveManagerUtils.GetRSAEncryptedKey();

            SwrveManager.Log("### eskKey: " + rSAEncryptedKey);
            if (!string.IsNullOrEmpty(rSAEncryptedKey))
            {
                dictionary.Add("esk", rSAEncryptedKey);
            }
            if (this.customUserData != null)
            {
                foreach (KeyValuePair <string, string> current in this.customUserData)
                {
                    if (!dictionary.ContainsKey(current.Key))
                    {
                        dictionary.Add(current.Key, current.Value);
                    }
                    else
                    {
                        SwrveManager.Log("###Duplicate KEY!! unable to add " + current.Key + " - " + current.Value);
                    }
                }
            }
            SwrveComponent.Instance.SDK.UserUpdate(dictionary);
            this.resourceManager = SwrveComponent.Instance.SDK.ResourceManager;
        }
Exemple #2
0
    private IEnumerator initSwrve()
    {
        DateTime        dateTime = new DateTime(2018, 12, 21, 0, 0, 0);
        ICPSwrveService instance;

        if (EnableAnalyticsLogging && dateTime.Date > DateTime.Now.Date && !Service.Get <GameSettings>().OfflineMode)
        {
            SwrveLog.OnLog += delegate(SwrveLog.LogLevel level, object message, string tag)
            {
                switch (level)
                {
                case SwrveLog.LogLevel.Verbose:
                    break;

                case SwrveLog.LogLevel.Info:
                    break;

                case SwrveLog.LogLevel.Warning:
                    break;

                case SwrveLog.LogLevel.Error:
                    Log.LogNetworkError("Swrve", message.ToString());
                    break;
                }
            };
            GameObject     gameObject     = Service.Get <GameObject>();
            SwrveComponent swrveComponent = gameObject.AddComponent <SwrveComponent>();
            Configurator   configurator   = Service.Get <Configurator>();
            IDictionary <string, object> dictionaryForSystem = configurator.GetDictionaryForSystem("SwrveConfig");
            string key = "PROD";
            IDictionary <string, object> dictionary = (IDictionary <string, object>)dictionaryForSystem[key];
            string key2 = "windows";
            IDictionary <string, object> dictionary2 = (IDictionary <string, object>)dictionary[key2];
            SwrveConfig swrveConfig = new SwrveConfig();
            swrveConfig.AppVersion = ClientInfo.Instance.BuildVersion;
            swrveConfig.AutomaticSessionManagement        = true;
            swrveConfig.AutoDownloadCampaignsAndResources = true;
            swrveConfig.NewSessionInterval              = 1;
            swrveConfig.UseHttpsForEventsServer         = true;
            swrveConfig.UseHttpsForContentServer        = true;
            swrveConfig.MessagingEnabled                = false;
            swrveConfig.ConversationsEnabled            = false;
            swrveComponent.SDK.PushNotificationListener = new CPSwrvePushNotificationListener();
            swrveComponent.Init((int)dictionary2["AppId"], (string)dictionary2["APIKey"], swrveConfig);
            Dictionary <string, string> deviceInfo = swrveComponent.SDK.GetDeviceInfo();
            string text   = deviceInfo["swrve.device_name"];
            string value  = deviceInfo["swrve.os"];
            string value2 = deviceInfo["swrve.device_dpi"];
            string value3 = deviceInfo["swrve.device_width"];
            string value4 = deviceInfo["swrve.device_height"];
            Dictionary <string, string> dictionary3 = new Dictionary <string, string>();
            dictionary3.Add("device_name", text);
            dictionary3.Add("os", value);
            dictionary3.Add("device_dpi", value2);
            dictionary3.Add("device_width", value3);
            dictionary3.Add("device_height", value4);
            if (!string.IsNullOrEmpty(swrveComponent.SDK.UserId))
            {
                dictionary3.Add("swrve_user_id", swrveComponent.SDK.UserId);
            }
            dictionary3.Add("jailbroken.is_jailbroken", SwrveManagerUtils.GetIsJailBroken());
            dictionary3.Add("lat.is_lat", SwrveManagerUtils.GetIsLat().ToString());
            string key3 = string.Empty;
            if (Application.platform == RuntimePlatform.Android)
            {
                key3 = "gida";
            }
            else if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                key3 = "idfa";
            }
            string value5 = SwrveManagerUtils.AESEncrypt(text, SwrveManagerUtils.GetAdvertiserID());
            dictionary3.Add(key3, value5);
            string rSAEncryptedKey = SwrveManagerUtils.GetRSAEncryptedKey();
            dictionary3.Add("esk", rSAEncryptedKey);
            swrveComponent.SDK.UserUpdate(dictionary3);
            instance = new CPSwrveService(swrveComponent);
        }
        else
        {
            instance = new NullCPSwrveService();
        }
        Service.Set(instance);
        yield break;
    }
        private void FinishSwrveSDKInit()
        {
            SwrveConfig swrveConfig = customSwrveConfig;

            SwrveComponent.Instance.Init(int.Parse(AnalyticsId), AnalyticsKey, customSwrveConfig);
            Dictionary <string, string> deviceInfo = SwrveComponent.Instance.SDK.GetDeviceInfo();
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            if (deviceInfo != null && deviceInfo.Count > 0)
            {
                string text   = deviceInfo["swrve.device_name"];
                string value  = deviceInfo["swrve.os"];
                string value2 = deviceInfo["swrve.device_dpi"];
                string value3 = deviceInfo["swrve.device_width"];
                string value4 = deviceInfo["swrve.device_height"];
                dictionary.Add("device_name", text);
                dictionary.Add("os", value);
                dictionary.Add("device_dpi", value2);
                dictionary.Add("device_width", value3);
                dictionary.Add("device_height", value4);
                if (!string.IsNullOrEmpty(swrveConfig.UserId))
                {
                    dictionary.Add("swrve_user_id", swrveConfig.UserId);
                }
                else
                {
                    Log("### !!! unable to add userId to the userProps");
                }
                dictionary.Add("jailbroken.is_jailbroken", SwrveManagerUtils.GetIsJailBroken());
                dictionary.Add("lat.is_lat", SwrveManagerUtils.GetIsLat().ToString());
                string text2 = string.Empty;
                if (Application.platform == RuntimePlatform.Android)
                {
                    text2 = "gida";
                }
                else if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    text2 = "idfa";
                }
                if (SwrveManagerUtils.IsAndiAvailable() && SwrveManagerUtils.IsAndiInitialized())
                {
                    string text3 = (string)SwrveManagerUtils.ANDIType.GetMethod("GetAndiu").Invoke(null, null);
                    Log("### Let's send Swrve the andiu: " + text3);
                    dictionary.Add("andiu", text3);
                }
                string text4 = SwrveManagerUtils.AESEncrypt(text, SwrveManagerUtils.GetAdvertiserID());
                Log("### encryptedAdvertiserId: " + text4);
                if (!string.IsNullOrEmpty(text2))
                {
                    dictionary.Add(text2, text4);
                }
                string rSAEncryptedKey = SwrveManagerUtils.GetRSAEncryptedKey();
                Log("### eskKey: " + rSAEncryptedKey);
                if (!string.IsNullOrEmpty(rSAEncryptedKey))
                {
                    dictionary.Add("esk", rSAEncryptedKey);
                }
            }
            else
            {
                Log("### !! Unable to get deviceInfo and therefore unable to get and set the userProperties information.");
            }
            if (customUserData != null)
            {
                foreach (KeyValuePair <string, string> customUserDatum in customUserData)
                {
                    if (!dictionary.ContainsKey(customUserDatum.Key))
                    {
                        dictionary.Add(customUserDatum.Key, customUserDatum.Value);
                    }
                    else
                    {
                        Log("###Duplicate KEY!! unable to add " + customUserDatum.Key + " - " + customUserDatum.Value);
                    }
                }
            }
            SwrveComponent.Instance.SDK.UserUpdate(dictionary);
            resourceManager = SwrveComponent.Instance.SDK.ResourceManager;
        }