Example #1
0
        public void StopTrackingMe()
        {
            lock (_lock) {
                if (!PlayerPrefs.HasKey(PF_KEY_STOP_TRACKING_ME))
                {
                    var started = HasStarted;
                    delegated.StopTrackingMe();

                    delegated = new DDNANonTracking(this);
                    if (started)
                    {
                        delegated.StartSDK(false);
                    }
                    delegated.StopTrackingMe();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Forgets the current user and stops them from being tracked.
        ///
        /// Any subsequent calls on the SDK will succeed, but not send/request anything to/from
        /// the Platform.
        ///
        /// The status can be cleared by starting the SDK with a new use or clearing the persistent
        /// data.
        /// </summary>
        public void ForgetMe()
        {
            lock (_lock) {
                if (!PlayerPrefs.HasKey(PF_KEY_FORGET_ME))
                {
                    var started = HasStarted;
                    delegated.ForgetMe();

                    delegated = new DDNANonTracking(this);
                    if (started)
                    {
                        delegated.StartSDK(false);
                    }
                    delegated.ForgetMe();
                }
            }
        }
Example #3
0
        /// <summary>
        /// Starts the SDK.  Call before sending events or making engagements.  This method
        /// can be used if the game configuration needs to be provided in the code as opposed
        /// to using the configuration UI.
        /// </summary>
        /// <param name="config">The game configuration for the SDK.</param>
        /// <param name="userID">The user id for the player, if set to null we create one for you.</param>
        public void StartSDK(Configuration config, string userID)
        {
            lock (_lock) {
                bool newPlayer = false;
                if (String.IsNullOrEmpty(UserID))           // first time!
                {
                    newPlayer = true;
                    if (String.IsNullOrEmpty(userID))       // generate a user id
                    {
                        userID = GenerateUserID();
                    }
                }
                else if (!String.IsNullOrEmpty(userID))     // use offered user id
                {
                    if (UserID != userID)
                    {
                        newPlayer = true;
                    }
                }

                UserID = userID;

                if (newPlayer)
                {
                    Logger.LogInfo("Starting DDNA SDK with new user " + UserID);
                }
                else
                {
                    Logger.LogInfo("Starting DDNA SDK with existing user " + UserID);
                }

                EnvironmentKey = (config.environmentKey == 0)
                    ? config.environmentKeyDev
                    : config.environmentKeyLive;
                CollectURL = config.collectUrl;
                EngageURL  = config.engageUrl;
                if (Platform == null)
                {
                    Platform = ClientInfo.Platform;
                }

                if (!string.IsNullOrEmpty(config.hashSecret))
                {
                    HashSecret = config.hashSecret;
                }
                if (config.useApplicationVersion)
                {
                    ClientVersion = Application.version;
                }
                else if (!string.IsNullOrEmpty(config.clientVersion))
                {
                    ClientVersion = config.clientVersion;
                }

                if (newPlayer)
                {
                    PlayerPrefs.DeleteKey(PF_KEY_FIRST_SESSION);
                    PlayerPrefs.DeleteKey(PF_KEY_LAST_SESSION);
                    PlayerPrefs.DeleteKey(PF_KEY_CROSS_GAME_USER_ID);

                    if (delegated is DDNANonTracking)
                    {
                        PlayerPrefs.DeleteKey(PF_KEY_FORGET_ME);
                        PlayerPrefs.DeleteKey(PF_KEY_FORGOTTEN);
                        PlayerPrefs.DeleteKey(PF_KEY_STOP_TRACKING_ME);

                        delegated = new DDNAImpl(this);
                    }
                }

                delegated.StartSDK(newPlayer);

                if (Settings.SendGameRunningEveryMinute)
                {
                    gameRunningEventCoroutine = GameHeartbeat(gameRunningEventInterval);
                    StartCoroutine(gameRunningEventCoroutine);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Starts the SDK.  Call before sending events or making engagements.  This method
        /// can be used if the game configuration needs to be provided in the code as opposed
        /// to using the configuration UI.
        /// </summary>
        /// <param name="config">The game configuration for the SDK.</param>
        /// <param name="userID">The user id for the player, if set to null we create one for you.</param>
        public void StartSDK(Configuration config, string userID)
        {
            lock (_lock) {
                bool newPlayer = false;
                if (String.IsNullOrEmpty(UserID))           // first time!
                {
                    newPlayer = true;
                    if (String.IsNullOrEmpty(userID))       // generate a user id
                    {
                        userID = GenerateUserID();
                    }
                }
                else if (!String.IsNullOrEmpty(userID))     // use offered user id
                {
                    if (UserID != userID)
                    {
                        newPlayer = true;
                    }
                }

                UserID = userID;

                if (newPlayer)
                {
                    Logger.LogInfo("Starting DDNA SDK with new user " + UserID);
                }
                else
                {
                    Logger.LogInfo("Starting DDNA SDK with existing user " + UserID);
                }

                EnvironmentKey = (config.environmentKey == 0)
                    ? config.environmentKeyDev
                    : config.environmentKeyLive;
                CollectURL = config.collectUrl;
                EngageURL  = config.engageUrl;
                if (Platform == null)
                {
                    Platform = ClientInfo.Platform;
                }

                if (!string.IsNullOrEmpty(config.hashSecret))
                {
                    HashSecret = config.hashSecret;
                }
                if (config.useApplicationVersion)
                {
                    ClientVersion = Application.version;
                }
                else if (!string.IsNullOrEmpty(config.clientVersion))
                {
                    ClientVersion = config.clientVersion;
                }

                if (newPlayer && delegated is DDNANonTracking)
                {
                    PlayerPrefs.DeleteKey(PF_KEY_FORGET_ME);
                    PlayerPrefs.DeleteKey(PF_KEY_FORGOTTEN);

                    delegated = new DDNAImpl(this);
                }

                delegated.StartSDK(newPlayer);
            }
        }