Simple example please, it doesn't work for me

Hi ! I tried to use it but I don’t know if I did mistake or if it simple doesn’t work.

Unity 2019.1.6f1
Remote Config 1.0.5

ConfigManager.FetchCompleted += response =>
{
    if (response.status == ConfigRequestStatus.Success)
    {
        Debug.LogFormat("toto: {0}", ConfigManager.appConfig.GetString("toto"));
        Debug.LogFormat("titi: {0}", ConfigManager.appConfig.GetInt("titi"));
    }
    else
        Debug.LogError("Remote config : " + response.status);
};

output is always 0 or null

Thank you in advance.

Hi hexaJer!

It’s not 100% clear in the docs (we’ll be updating it soon to be more clear), but ConfigManager.FetchConfigs needs to be called in order for Remote Config to fetch the config you need. Here’s an example:

public struct UserAttributes {
    //any attributes you might want to use for segmentation, empty if nothing
}
public struct AppAttributes {
    //any attributes you might want to use for segmentation, empty if nothing
}

public class UseRemoteConfig : MonoBehaviour
{
    void Awake()
    {
        ConfigManager.FetchCompleted += response =>
        {
            if (response.status == ConfigRequestStatus.Success)
            {
                Debug.LogFormat("toto: {0}", ConfigManager.appConfig.GetString("toto"));
                Debug.LogFormat("titi: {0}", ConfigManager.appConfig.GetInt("titi"));
            }
            else
                Debug.LogError("Remote config : " + response.status);
         };
        ConfigManager.FetchConfigs<UserAttributes, AppAttributes>(new UserAttributes(), new AppAttributes());
    }
}
3 Likes

Thank you ! It work !

The *Custom attributes are entirely optional* and // Optionally declare variables for any custom user attributes lines
in the documentation suggest it’s not required to declare userAttributes and appAttributes structs and fetch them.

Perhaps comments placed here would be clearer.

// not here
public struct userAttributes {
    // Optionally declare variables for any custom user attributes:
    public bool expansionFlag;
}

public struct appAttributes {
    // Optionally declare variables for any custom app attributes:
    public int level;
    public int score;
    public string appVersion;
}

It work but push config with editor randomly cause HTTP Bad Request error with really simple rules
like app.level==5 as condition and titi setting set to 5 instead of 2.
push… error
disable titi change in rule, push… it work
re enable titi change, push… it work
change titi = 6 in rule… error

@hexaJer Could you copy the Console error(s) you are encountering here please?