Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Updating remote values at intervals

Discussion in 'Unity Remote Config' started by Steve_Xisle, Oct 23, 2019.

  1. Steve_Xisle


    Feb 20, 2019

    Is it possible to call FetchConfigs multiple times during the game's lifetime?

    I would like to pull values every 10 minutes to ensure nothing has changed.

    In my current implementation the first call to FetchConfigs works (pulls values from remote), then subsequent calls seem to do nothing. Am i missing something or is this not possible?

  2. rambod


    Unity Technologies

    Mar 2, 2018
    Hi @Steve_Xisle,

    Yep, we've designed Remote Config to be called whenever you want, as many times as you want.

    Can you paste a code snippet of how you're fetching Remote Config? My first guess is that maybe there aren't any changes between the first fetch and subsequent fetches, but seeing the code will help with that.
  3. Steve_Xisle


    Feb 20, 2019
    Sure, i'm using v1.0.6. The first call to Fetch() works fine, ApplyRemoteSettings is called. After that first time any subsequent calls to Fetch do not result in ApplyRemoteSettings being called

    Code (CSharp):
    1.     public class UnityRemoteConfigService : IRemoteConfigService
    2.     {
    3.         private struct UserAttributes
    4.         {
    5.         }
    7.         private struct AppAttributes
    8.         {
    9.         }
    11.         private bool _fetched;
    13.         public UnityRemoteConfigService()
    14.         {
    15.             ConfigManager.FetchCompleted += ApplyRemoteSettings;
    16.         }
    18.         public void Fetch()
    19.         {
    20.             Logger.Instance.LogInfo("Unity Remote Config: Fetching...");
    21.             ConfigManager.FetchConfigs(new UserAttributes(), new AppAttributes());
    22.         }
    24.         private void ApplyRemoteSettings(ConfigResponse configResponse)
    25.         {
    26.             switch (configResponse.requestOrigin)
    27.             {
    28.                 case ConfigOrigin.Default:
    29.                     Logger.Instance.LogInfo("Unity Remote Config: No settings loaded this session; using default values.");
    30.                     break;
    31.                 case ConfigOrigin.Cached:
    32.                     Logger.Instance.LogInfo("Unity Remote Config: No settings loaded this session; using cached values from a previous session.");
    33.                     break;
    34.                 case ConfigOrigin.Remote:
    35.                     Logger.Instance.LogInfo("Unity Remote Config: New settings loaded this session; updating values accordingly.");
    36.                     _fetched = true;
    37.                     break;
    38.             }
    39.         }
    41.         public bool GetValue(string key, out string value)
    42.         {
    43.             if (!_fetched || !ConfigManager.appConfig.HasKey(key))
    44.             {
    45.                 value = null;
    46.                 return false;
    47.             }
    49.             value = ConfigManager.appConfig.GetString(key);
    50.             return true;
    51.         }
    52.     }
  4. rambod


    Unity Technologies

    Mar 2, 2018
    Hmm, I tried using your code snippet and I was able to trigger the callback multiple times. Is there a chance somewhere else the event handler is being removed? The other thing that comes to mind is maybe there's already another request in progress, but if you're calling it once every ten minutes that seems extremely unlikely.

    If neither of those seem plausible, maybe we can hop on a call and do a deep dive on the issue you're seeing if you'd be open to it.