Remote Config SDK API 参考

RemoteConfigService

public sealed class RemoteConfigService

此类用于在运行时获取并应用配置设置。RemoteConfigService 是封装类,用于模拟底层 ConfigManagerImpl 类的功能。它使用 ConfigManagerImpl 类的实例,因此是 ConfigManagerImpl 的原始类。

FetchCompleted

public event Action<ConfigResponse> FetchCompleted

此事件触发配置管理器成功从该服务获取设置。它会返回代表 Remote Config 获取响应的结构。

appConfig

public RuntimeConfig appConfig

检索用于处理 Remote Config 设置的 RuntimeConfig 对象。此属性用于访问以下方法和类:

方法描述
public string assignmentID用于报告和分析目的的唯一字符串标识符。Remote Config 服务会在收到配置请求时生成此 ID。
public bool GetBool (string key, bool defaultValue)从远程服务检索相应密钥的布尔值(如果有)。
public float GetFloat (string key, float defaultValue)从远程服务检索相应密钥的浮点值(如果有)。
public long GetLong (string key, long defaultValue)从远程服务检索相应密钥的长数值(如果有)。
public int GetInt (string key, int defaultValue)从远程服务检索相应密钥的整数值(如果有)。
public string GetString (string key, string defaultValue)从远程服务检索相应密钥的字符串值(如果有)。
public bool HasKey (string key)检查您的远程设置中是否存在相应密钥。
public string[] GetKeys ()以数组形式返回远程设置中的所有密钥。
public string[] GetJson ()从远程服务返回相应密钥的 JSON 值的字符串表示形式(如果有)。

GetConfig

public RuntimeConfig GetConfig(string configType)

通过传递 configType 来从多个配置对象检索特定配置。

SetCustomUserID

public void SetCustomUserID(string customUserID)

设置 Remote Config 传递请求有效负载的自定义用户标识符。

SetEnvironmentID

public void SetEnvironmentID(string environmentID)

设置 Remote Config 传递请求有效负载的环境标识符。

SetPlayerIdentityTokenID

public void SetPlayerIdentityTokenID(string playerIdentityTokenID)

设置玩家身份令牌。

SetUserID

public void SetUserID(string iid)

userId 设置为来自 Core 服务的 InstallationID 标识符。

SetPlayerID

public void SetPlayerID(string playerID)

设置来自 Authentication 服务的玩家标识符。

SetAnalyticsUserID

public void SetAnalyticsUserID(string analyticsUserID)

设置来自 Core 服务的分析用户标识符。

SetConfigAssignmentHash

public void SetConfigAssignmentHash(string confiAssignmentHashID)

设置来自 Core 服务的 configAssignmentHash 标识符。

FetchConfigsAsync

public Task<RuntimeConfig> FetchConfigsAsync<T, T2, T3>(string configType, T userAttributes, T2 appAttributes, T3 filterAttributes)

从远程服务器获取应用配置设置。

参数描述
configType包含 cofigType 的字符串。如果都不适用,请使用空字符串。
userAttributes包含自定义用户属性的结构。如果都不适用,请使用空结构。
appAttributes包含自定义应用属性的结构。如果都不适用,请使用空结构。
filterAttributes包含自定义过滤器属性的结构。如果都不适用,请使用空结构。
TuserAttributes 结构的类型。
T2appAttributes 结构的类型。
T3filterAttributes 结构的类型。

枚举

ConfigOrigin

一种枚举,用于描述最近加载的配置设置的起点。

描述
Default表示当前会话中没有加载任何配置设置。
Cached表示当前会话中加载的配置设置是从之前会话缓存的(也就是说没有加载任何新的配置设置)。
Remote表示当前会话中从远程服务器加载了新的配置设置。

ConfigRequestStatus

一种枚举,用于表示当前 Remote Config 请求的状态。

描述
None表示尚未发出任何 Remote Config 请求。
Failed表示 Remote Config 请求失败。
Success表示 Remote Config 请求成功。
Pending表示 Remote Config 请求仍在处理中。