> For the complete documentation index, see [llms.txt](https://lionstudios.gitbook.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lionstudios.gitbook.io/readme/features/remote-configs.md).

# Remote Configs

## **Introduction**

`Lion  - Remote Configs`  package is designed to help your game studio gain insights into your player base and identify actionable opportunities for growing your audience and revenue.

The features that Remote Configs provides are,

Remote Configs automatically:

* initializes selected Remote Configs solution (e.g., Firebase)
* Sets essential properties
* Logs important data (experiment name, etc.) to Analytics
* Fetches and stores Feature Flag values

Remote Configs also provides simple functions to:

* Access Feature Flag (remote configuration) values
* Fire Events (to assign payers to audiences)
* Set Custom Properties

### Installation Guide

* Make sure LionSDK is installed. Complete the steps in [Getting Started](/readme/getting-started.md) first.
* Install `Lion - Remote Configs` from the Unity package manager.\
  ![](/files/OsOGrBjqg0PTOHGONAGb)

### Setup

Remote Configs solution has three types. Either of them can be configured in editor, but **only one of them will be used at runtime**. The three types of Remote Configs solution are:

* [Firebase](/readme/features/remote-configs/firebase.md) (recommended)
* [Local Testing](/readme/features/remote-configs/test-adapter.md) (*For local testing*)

Setup instructions for each solution are provided in the links above. After setting it up, you can select it by going to `LionStudios → Settings Manager → Remote Configs` .

<figure><img src="/files/5EgJ4Z5oQhrrXqUfaMVS" alt=""><figcaption><p>Remote Config Adapter Selection Menu</p></figcaption></figure>

{% hint style="info" %}
The Remote Configs solutions need to load their values before the gameplay starts. The easiest solution for this is to integrate our [Loading Scene](/readme/features/loading-scene.md) module.
{% endhint %}

## Usage

{% hint style="warning" %}
Remote Config package methods must be called after the Remote Configs package has been initialized. The module is part of LionSDK’s initialization cycle; you can use `RemoteConfigsController.IsInitialized` and `RemoteConfigsController.OnInitialized` to ensure that it is ready.
{% endhint %}

Example usage of waiting for remote configs to be initialized:

```
if (RemoteConfigsController.IsInitialized)
{
    SetRemoteConfig();
}
else
{
    RemoteConfigsController.OnInitialized += SetRemoteConfig;
}
```

{% stepper %}
{% step %}

### Remote values

Remote values give the ability to change the behavior and appearance of your app without publishing an app update for users.

* For Firebase, Remote value means **Parameters**
* For Test, Remote value means the **local list of values** present in the editor window

**Function signature**

```csharp
 RemoteConfigsController.GetValue<T>(string flagName, T defaultValue)
```

This will return the value of the remote values for the current player.

**Examples**

```csharp
// If no flag exists for that key or if offline, it will return the 
// default value (3).
int showAppReviewAfterLevel = 
	RemoteConfigsController.GetValue<int>("show_app_review_after_level", 3);
```

```csharp
// Any type can be used. The flag value will be parsed to that type.
// For complex types, the remote value has to be formatted in json.
bool bonusLevelEnabled = 
	RemoteConfigsController.GetValue<bool>("bonus_level_enabled", false);	
```

{% endstep %}

{% step %}

### Log Event

Events allow you to send data for a given user to the server for processing.

* For Firebase, the events are created at runtime, so you just need to call the “LogEvent” function with events.
* For Test, the events are just Debug logs.

**Function signature**

```csharp
LiveopsController.LogEvent(
	string name, 
	string value, 
	Dictionary<string, string> metadata = null)
```

**Example**

```csharp
// This will log an event named "iap_purchase", with a value of "verified"
LiveopsController.LogEvent("iap_purchase", "verified");
```

{% endstep %}

{% step %}

### Fetching data

* For Firebase, by calling the “FetchAndUpdateRemoteConfig” function, only remote configs are updated by fetching them from the server.
* For Test, By calling the “FetchAndUpdateRemoteConfig” function, it will fetch the latest values present in the editor window. But in runtime, this won’t do anything as values in the Unity editor will be the same every time.

**Function signature**

The given function is an async task function; “await” can be used here, which ensures that the code waits until the data is fetched completely from the server.

```csharp
LiveOpsController.FetchAndUpdateRemoteConfig();
```

**Example**

```csharp

bool isFetchedCorrectly = await LiveOpsController.FetchAndUpdateRemoteConfig();

if (isFetchedCorrectly)
{
    //Do something here after fetching
}
```

{% endstep %}

{% step %}

### Custom/User properties

Properties are an important tool used to define and enrich a user identity profile, and ultimately used to define the audience segments.

* For Firebase, more information can be found here: [Firebase user properties](https://firebase.google.com/docs/analytics/user-properties)
* For testing, there are no user properties. Setting them won’t do anything.

**Function signature**

```csharp
//Key parameter is the property ID
//Value parameter is the property's actual value
public static void SetCustomProperty(string key, string value)

//Another way to set properties is to send the whole dictionary
//Dictionary's first 'string' denotes the key of the property
//Dictionary's second 'string' denotes the value of the property
public static void SetCustomProperties(Dictionary<string, string> customProperties)
```

**Example-1**

```csharp
LiveOpsController.SetCustomProperty("Age", "23");
```

**Example-2**

```csharp
	Dictionary<string, string> dictionary = new Dictionary<string, string>()
  {
      { "Age", "23"},
      { "Name", "Anything"}
  };

  LiveOpsController.SetCustomProperties(dictionary);
```

{% endstep %}

{% step %}

### Existing user

A boolean value that’s used to identify players who have previously played the app in a version without Remote Configs (Firebase). These players must be processed differently internally because the Remote Configs SDK (Firebase) has incomplete data on them.

So at the start of the first session with Remote Configs, you need to let us know if the player has existed before that session. You can use your own persistent data to check this.

Make sure to call this only once.

Pass “true” if the user existed before.

```csharp
//Send a boolean value as a parameter indicating whether this is a new user or not.
public static void SetExistingUserProperty(bool value)
```

**Example**

```csharp
if (!PlayerPrefs.HasKey("HasSetExistingUserProperty"))
{
    bool userExistedBefore = PlayerPrefs.GetInt("CurrentLevel", 0) > 0;
    LiveOpsController.SetExistingUserProperty(userExistedBefore);
    PlayerPrefs.SetInt("HasSetExistingUserProperty", 1);
}
```

{% endstep %}

{% step %}

### Set up experiments

Below are the instructions to set up AB Experiments on the dashboard so that the module can send appropriate events to Lion Analytics:

* For Firebase: [AB Experiments (Firebase)](/readme/features/remote-configs/firebase/ab-experiments-firebase.md)
  {% endstep %}

{% step %}

### Generating JSON Remote Config Values

The Remote Config provides a feature which can help you generate formatted JSON for your complex data. Refer [here](https://app.gitbook.com/o/tefS2huU8g4cEbvtYdJ6/s/O3Jns0MMUpUIoCo5ylWF/~/edit/~/changes/121/readme/features/remote-configs/advanced#generating-json-remote-config-values) for more information.
{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://lionstudios.gitbook.io/readme/features/remote-configs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
