示例#1
0
        /// <summary>
        /// When a PlayFab login occurs, check the result information, and
        ///   relay it to _OnPlayFabLogin where the information is used
        /// </summary>
        /// <param name="result"></param>
        public static void OnPlayFabLogin(PlayFabResultCommon result)
        {
            var loginResult    = result as ClientModels.LoginResult;
            var registerResult = result as ClientModels.RegisterPlayFabUserResult;

            if (loginResult == null && registerResult == null)
            {
                return;
            }

            // Gather things common to the result types
            ClientModels.UserSettings settingsForUser = null;
            string playFabId = null;

            ClientModels.EntityTokenResponse entityInfo = null;

            if (loginResult != null)
            {
                settingsForUser = loginResult.SettingsForUser;
                playFabId       = loginResult.PlayFabId;
                entityInfo      = loginResult.EntityToken;
            }
            else if (registerResult != null)
            {
                settingsForUser = registerResult.SettingsForUser;
                playFabId       = registerResult.PlayFabId;
                entityInfo      = registerResult.EntityToken;
            }

            _OnPlayFabLogin(settingsForUser, playFabId, entityInfo);
        }
示例#2
0
        /// <summary>
        /// Separated from OnPlayFabLogin, to explicitly lose the refs to loginResult and registerResult, because
        ///   only one will be defined, but both usually have all the information we REALLY need here.
        /// But the result signatures are different and clunky, so do the separation above, and processing here
        /// </summary>
        private static void _OnPlayFabLogin(ClientModels.UserSettings settingsForUser, string playFabId, ClientModels.EntityTokenResponse entityInfo)
        {
            _needsAttribution = _gatherDeviceInfo = _gatherScreenTime = false;
            if (settingsForUser != null)
            {
                _needsAttribution = settingsForUser.NeedsAttribution;
                _gatherDeviceInfo = settingsForUser.GatherDeviceInfo;
                _gatherScreenTime = settingsForUser.GatherFocusInfo;
            }

            // Device attribution (adid or idfa)
            if (PlayFabSettings.AdvertisingIdType != null && PlayFabSettings.AdvertisingIdValue != null)
            {
                DoAttributeInstall();
            }
            else
            {
                GetAdvertIdFromUnity();
            }

            // Device information gathering
            SendDeviceInfoToPlayFab();

#if ENABLE_PLAYFABENTITY_API
            string playFabUserId             = playFabId;
            EntityModels.EntityKey entityKey = new EntityModels.EntityKey();
            if (entityInfo != null && _gatherScreenTime)
            {
                entityKey.Id         = entityInfo.Entity.Id;
                entityKey.Type       = (EntityModels.EntityTypes)(int) entityInfo.Entity.Type; // possible loss of data
                entityKey.TypeString = entityInfo.Entity.TypeString;

                PlayFabHttp.InitializeScreenTimeTracker(entityKey, playFabUserId);
            }
            else
            {
                PlayFabSettings.DisableFocusTimeCollection = true;
            }
#endif
        }