Remote configuration
To retrieve a remote flag configuration (Remote Config), use the ysdk.getFlags() method from the Yandex Games SDK. We recommend requesting the flags once at your game startup.
Signature and interfaces of the method
1interface IFlags {
2 [key: string]: string;
3}
4
5interface IClientFeature {
6 name: string;
7 value: string;
8}
9
10interface IGetFlagsParams {
11 defaultFlags?: IFlags;
12 clientFeatures?: IClientFeature[];
13}
14
15function getFlags(getFlagsParams: IGetFlagsParams = {}): IFlags {}
Accepts parameters:
|
Parameter |
Type |
Description |
|
|
|
Client parameter name. |
|
|
|
Client parameter value. |
|
|
|
Local configuration: a flat object with key-value pairs. Corresponds to the remote configuration set in the Console. |
|
|
|
Array with client parameters. Contains player data. |
Example
1const ysdk = await YaGames.init();
2
3const flags = await ysdk.getFlags(); // This method returns an object with flags.
4
5// You can add this condition to your game logic:
6if (flags.difficult === 'hard') {
7 // Increasing the game difficulty.
8}
Local configuration
Tip
Always add a local configuration of flags to the game code in case the remote configuration cannot be fetched from the server (for example, due to internet connection issues).
To add local configuration (a flat object containing string values), pass it in the additional parameter of the ysdk.getFlags() method, in the defaultFlags field. The resulting object is a combination of the remote and local configurations. The remote configuration has a higher priority.
Example
1const ysdk = await YaGames.init();
2
3const flags = await ysdk.getFlags({ defaultFlags: { difficult: 'easy' } });
4
5if (flags.difficult === 'easy') {
6}
Client parameters
If your game stores player data (completed levels, experience, in-app purchases, etc.), it can be used in remote configuration. For more information on how to configure a flag based on conditions, see Step 1. Create a flag configuration.
Client parameters must be passed as an array in the clientFeatures field of the ysdk.getFlags() method.
Example
1const ysdk = await YaGames.init();
2
3const player = await ysdk.getPlayer();
4
5const payingStatus = player.getPayingStatus();
6
7// Requesting the flags with the client parameter containing the user's payment activity status.
8const flags = await ysdk.getFlags({
9 clientFeatures: [{ name: 'payingStatus', value: payingStatus }]
10});
Note
Support staff help you publish a ready-made game on the Yandex Games platform. For applied questions about development and testing, other developers will answer in the Discord community.
If you encounter a problem or have a question while using the Yandex Games SDK, contact support: