Search Unity

Question How to use custom configType when fetching values?

Discussion in 'Unity Remote Config' started by radu1234, Feb 28, 2022.

  1. radu1234

    radu1234

    Joined:
    Feb 18, 2014
    Posts:
    2
    Hello,

    I've been trying to use the ConfigManager.FetchConfigs<T, T2, T3> (string configType, T userAttributes, T2 appAttributes, T3 filterAttributes) method with a custom configType, but the response returned is always an empty json.

    The context is that I want to split the config file in two, the default part with the default "settings" configType that gets overwritten every time I fetch, and a custom part with custom configType that stays the same for a long time until I need to update it and call fetch again. The default part works well and retrieves the values every time, but the custom configType only returns an empty json.

    This is how the file ends up (I marked where values are missing):

    {
    "settings": {
    "requestOrigin": 2,
    "status": 2,
    "body": {
    "configs": {
    "settings": {
    "av": "1.2.0",
    "cv": 2
    }
    },
    "metadata": {
    "configAssignmentHash": "***",
    "assignmentId": "***",
    "environmentId": "***"
    }
    },
    "headers": {
    "Date": "Mon, 28 Feb 2022 21:58:05 GMT",
    "Content-Type": "application/json;charset=utf-8",
    "Access-Control-Allow-Origin": "*",
    "Content-Length": "234",
    "Server": "Jetty(9.4.z-SNAPSHOT)",
    "Via": "1.1 google"
    }
    },
    "generalConfig": {
    "requestOrigin": 2,
    "status": 2,
    "body": {
    "configs": {
    "generalConfig": { /* HERE THERE SHOULD BE SOME KEY VALUE PAIRS */}
    },
    "metadata": {}
    },
    "headers": {
    "Date": "Mon, 28 Feb 2022 21:13:59 GMT",
    "Content-Type": "application/json;charset=utf-8",
    "Access-Control-Allow-Origin": "*",
    "Content-Length": "46",
    "Server": "Jetty(9.4.z-SNAPSHOT)",
    "Via": "1.1 google"
    }
    }
    }

    If I call fetch with default configType, I get the json in question, so it's not from that.

    I have searched for more info about this configType but there is almost no mention of it anywhere. Am I missing something, should I set the config type somewhere in the dashboard(though I searched everywhere and it's nothing), or am I not supposed to use the configType?

    Thanks,
    Radu
     
    Last edited: Feb 28, 2022
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @radu1234 Can you share the documentation that you are following, and the code that you are using?
     
  3. radu1234

    radu1234

    Joined:
    Feb 18, 2014
    Posts:
    2
    I am using remote config 2.1.2 with Unity 2018.4.36, the documentation can be found here : https://docs.unity3d.com/Packages/c...pl_FetchConfigs__3_System_String___0___1___2_

    Essentially I am calling it like this (code here is a bit simplified):

    Code (CSharp):
    1. public struct UserAttributes { }
    2. public struct AppAttributes { }  
    3.  
    4. private static FilterAttributes configJsonFilter = new FilterAttributes()
    5.     { key = new string[] { "cj" } };
    6.  
    7. RuntimeConfig generalConfig = ConfigManager.GetConfig("generalConfig");
    8. generalConfig.FetchCompleted -= GeneralCallback;//this is done in case I call the method twice, to not add the callback twice
    9. generalConfig.FetchCompleted += GeneralCallback;
    10.  
    11. ConfigManager.FetchConfigs("generalConfig", new UserAttributes(), new UserAttributes(), configJsonFilter);
    Thanks!
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Unfortunately Unity 2018 is no longer supported, and Unity 2019 will soon follow. Please use Remote Config 3.0.0-pre.11. Please share your exact code so I may reproduce here, Please remove the -= call for now, get the success path working first. Also, please elaborate on your requirements with sample data that you would expect to see in the running app, along with the values you are setting on the dashboard. It might be easiest if you created an example by starting with a new/empty project (not your full game) and add the minimum code necessary to reproduce. Then remove the /Library folder, zip it up and send it to me in a private message.