Search Unity

  1. Full schedule for #UniteBerlin is now available! Featuring talks on our roadmap, hands-on labs and much more! Check it out!
    Dismiss Notice
  2. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  3. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Remote Settings, update handler NOT always dispatched?

Discussion in 'Unity Analytics' started by Matthewek, Apr 3, 2018.

  1. Matthewek

    Matthewek

    Joined:
    Apr 6, 2015
    Posts:
    29
    Hello, I am in a process of implementing Remote Settings into my new game, however after testing on Android (Unity 2017.3) I have noticed update handler is NOT always dispatched. Documentation says:

    I am using development mode in remote settings,

    Code (CSharp):
    1. void Start()
    2. {
    3.     adDelay = defaultAdDelay;
    4.     adMain = defaultAdMain;
    5.     adOnExit = defaultAdOnExit;
    6.     adMediate = defaultAdMediate;
    7.  
    8.     RemoteSettings.Updated += new RemoteSettings.UpdatedEventHandler(HandleRemoteSettingsUpdate);
    9. }
    10.  
    11. private void HandleRemoteSettingsUpdate()
    12. {
    13.     adDelay = RemoteSettings.GetFloat("adDelay", defaultAdDelay);
    14.     adMain = RemoteSettings.GetInt("adMain", defaultAdMain);
    15.     adOnExit = RemoteSettings.GetBool("adOnExit", defaultAdOnExit);
    16.     adMediate = RemoteSettings.GetBool("adMediate", defaultAdMediate);
    17.     nextToDisplay = GetAdvertType(adMain);
    18.     Debug.Log("[AD MANAGER] handled remote update");
    19. }
    Unfortunately on android device, update is often not dispatched, is that stable feature or I am doing something wrong?

    EDIT:

    What I also noticed, that even after settings were fetched once from the server (update fire) and I closed the app, opened it again (no update fired) thus not cached (previously fetched) settings but default were used.
     
    Last edited: Apr 3, 2018
  2. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    904
    @Matthewek

    I would recommend this code:

    Code (CSharp):
    1. void Start()
    2. {
    3.     RemoteSettings.Updated += new RemoteSettings.UpdatedEventHandler(HandleRemoteSettingsUpdate);
    4.     HandleRemoteSettingsUpdate();
    5. }
    6.  
    7. private void HandleRemoteSettingsUpdate()
    8. {
    9.     adDelay = RemoteSettings.GetFloat("adDelay", defaultAdDelay);
    10.     adMain = RemoteSettings.GetInt("adMain", defaultAdMain);
    11.     adOnExit = RemoteSettings.GetBool("adOnExit", defaultAdOnExit);
    12.     adMediate = RemoteSettings.GetBool("adMediate", defaultAdMediate);
    13.     nextToDisplay = GetAdvertType(adMain);
    14.     Debug.Log("[AD MANAGER] handled remote update");
    15. }
    The basic change is calling HandleRemoteSettingsUpdate from within Start, which would ensure the variables are set with the last values received and if no config file exists on disk, they will be set with the default values.
     
    Matthewek likes this.