Remote configuration

To retrieve a remote flag configuration (Remote Config), use the getFlags() method from the Yandex Games SDK. We recommend requesting the flags once at your game startup.

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 embed local flag configuration in the game code in case the remote configuration cannot be retrieved 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 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
7}

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 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: [
10        { name: 'payingStatus', value: payingStatus }
11    ]
12});

Signature and interfaces of the getFlags() 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 {}

Note

Our support team can help publish finished games on Yandex Games. If you have any questions about development or testing, ask them in the Discord channel.

If you are facing an issue or have a question regarding the use of Yandex Games SDK, please contact support:

Write to chat