コード例 #1
0
    public override void Init(MonoBehaviour container, int appId, string apiKey, string userId)
    {
        SwrveConfig swrveConfig = new SwrveConfig();

        swrveConfig.UserId = userId;
        Init(container, 0, "", swrveConfig);
    }
コード例 #2
0
    /// <summary>
    /// Initialize the SDK.
    /// </summary>
    /// <param name="appId">
    /// ID for your app, as supplied by Swrve.
    /// </param>
    /// <param name="apiKey">
    /// Scret API key for your app, as supplied by Swrve.
    /// </param>
    /// <param name="config">
    /// Extra configuration for the SDK.
    /// </param>
    public void Init(int appId, string apiKey, SwrveConfig config = null)
    {
        if (SDK == null || SDK is SwrveEmpty)
        {
            bool supportedOSAndVersion = true;
#if !UNITY_EDITOR
#if UNITY_IPHONE
            supportedOSAndVersion = SwrveSDK.IsSupportediOSVersion();
#elif UNITY_ANDROID
            supportedOSAndVersion = SwrveSDK.IsSupportedAndroidVersion();
#else
#warning "We do not officially support this plaform. tracking is disabled."
            supportedOSAndVersion = false;
#endif
#elif !UNITY_IPHONE && !UNITY_ANDROID
#warning "We do not officially support this plaform. tracking is disabled."
            supportedOSAndVersion = false;
#endif
            if (supportedOSAndVersion)
            {
                SDK = new SwrveSDK();
            }
            else
            {
                SDK = new SwrveEmpty();
            }
        }
        if (config == null)
        {
            config = new SwrveConfig();
        }
        SDK.Init(this, appId, apiKey, config);
    }
コード例 #3
0
 public void InitWithAnalyticsKeySecretAndConfig(int appId, string apiKey, SwrveConfig customConfig)
 {
     if (customConfig != null)
     {
         SwrveComponent.Instance.Config = customConfig;
     }
     this.InitWithAnalyticsKeySecret(appId, apiKey);
 }
コード例 #4
0
 public void InitWithAnalyticsKeySecretAndConfig(int appId, string apiKey, SwrveConfig customConfig)
 {
     if (customConfig != null)
     {
         customSwrveConfig = customConfig;
     }
     InitWithAnalyticsKeySecret(appId, apiKey);
 }
コード例 #5
0
 public override void Init(MonoBehaviour container, int appId, string apiKey, SwrveConfig config = null)
 {
     this.Container       = container;
     this.ResourceManager = new SwrveUnity.ResourceManager.SwrveResourceManager();
     this.prefabName      = container.name;
     this.appId           = appId;
     this.apiKey          = apiKey;
     this.config          = config;
     this.Language        = config.Language;
     this.Initialised     = true;
 }
コード例 #6
0
 public override void Init(MonoBehaviour container, int appId, string apiKey, SwrveConfig config)
 {
     Container       = container;
     ResourceManager = new SwrveResourceManager();
     prefabName      = container.name;
     base.appId      = appId;
     base.apiKey     = apiKey;
     base.config     = config;
     userId          = config.UserId;
     Language        = config.Language;
     Initialised     = true;
 }
コード例 #7
0
    void Start()
    {
        SwrveConfig config = new SwrveConfig();

        // To use the EU stack, include this in your config.
        // config.SelectedStack = SwrveUnity.Stack.EU;

        //FIXME: FIX ME! Replace <app_id> and "<api_key>" with your app ID and API key.
#if PRODUCTION_BUILD
        SwrveComponent.Instance.Init(-1, "<production_api_key>", config);
#else
        SwrveComponent.Instance.Init(-1, "<dev_api_key>", config);
#endif
    }
コード例 #8
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         Object.DontDestroyOnLoad(base.gameObject);
         SwrveComponent swrveComponent = base.gameObject.AddComponent <SwrveComponent>();
         customSwrveConfig = new SwrveConfig();
     }
     else if (instance != this)
     {
         Object.Destroy(base.gameObject);
     }
 }
コード例 #9
0
 public void Init(int appId, string apiKey, SwrveConfig config = null)
 {
     if (SDK == null || SDK is SwrveEmpty)
     {
         if (true)
         {
             SDK = new SwrveSDK();
         }
         else
         {
             SDK = new SwrveEmpty();
         }
     }
     if (config == null)
     {
         config = new SwrveConfig();
     }
     SDK.Init(this, appId, apiKey, config);
 }
コード例 #10
0
        private void Start()
        {
            Stopwatch stopwatch = new Stopwatch();
            long      num       = stopwatch.RunTest(delegate
            {
                for (long num3 = 0L; (float)num3 < 5f; num3++)
                {
                    if (SwrveManager.instance == null)
                    {
                        swrveManager = (GameObject)Object.Instantiate(Resources.Load("SwrveManager"));
                    }
                    SwrveConfig customConfig = new SwrveConfig
                    {
                        PushNotificationEnabled      = true,
                        GCMSenderId                  = "1234567890",
                        AndroidPushNotificationTitle = "Profiler notifications",
                        UserId = "profiler"
                    };
                    Dictionary <string, string> customData = new Dictionary <string, string>
                    {
                        { "customData1", "fancy-custom-data-1" },
                        { "customData2", "fancy-custom-data-2" },
                        { "customData3", "fancy-custom-data-3" },
                        { "lat.is_lat", "this-should-not-overwrite" }
                    };
                    SwrveManager.DebugLogging = true;
                    SwrveManager.instance.InitWithAnalyticsKeySecretConfigAndCustomData(SWRVE_API_ID, SWRVE_API_KEY, customConfig, customData);
                    Object.Destroy(SwrveManager.instance.gameObject);
                    SwrveManager.instance = null;
                    swrveManager          = null;
                }
            });
            float num2 = (float)num / 5f;

            report = "Test, Total Test Time (milliseconds), Avg Test Time (milliseconds)\nSwrveManagerInit, " + num + ", " + num2 + "\n";
        }
コード例 #11
0
 public override void Init(MonoBehaviour container, int appId, string apiKey, string userId, SwrveConfig config)
 {
     config.UserId = userId;
     Init(container, 0, "", config);
 }
コード例 #12
0
 /// <summary>
 /// Reset is invoked when the component is added to the Game Object
 /// and is always called on the main thread.
 /// </summary>
 public void Reset()
 {
     Config = new SwrveConfig();
     SDK    = new SwrveSDK();
 }
コード例 #13
0
 /// <summary>
 /// Default constructor. Will be called by Unity when
 /// placing this script in your scene.
 /// </summary>
 public SwrveComponent()
 {
     Config = new SwrveConfig();
     SDK    = new SwrveSDK();
 }
コード例 #14
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;
        }
コード例 #15
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;
    }
コード例 #16
0
 public void InitWithAnalyticsKeySecretConfigAndCustomData(int appId, string apiKey, SwrveConfig customConfig = null, Dictionary <string, string> customData = null)
 {
     if (customData != null)
     {
         this.customUserData = customData;
     }
     this.InitWithAnalyticsKeySecretAndConfig(appId, apiKey, customConfig);
 }
コード例 #17
0
 public SwrveComponent()
 {
     this.Config = new SwrveConfig();
     this.SDK    = new SwrveEmpty();
 }
コード例 #18
0
        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;
        }