Skip to content

Dynamic Configuration

This document describes the remote configuration and proactive update capabilities of the React Native SDK.

Prerequisites

Dynamic configuration capabilities only take effect when FTMobileConfig.remoteConfiguration = true.

Listening for Remote Configuration Updates

After enabling remote configuration, you can listen for remote configuration update results automatically triggered by the SDK.

/**
 * Listens for remote configuration updates automatically triggered by the native SDK.
 * The Promise returned by calling the proactive sync dynamic configuration method will not be delivered via this event callback.
 */
addRemoteConfigListener(
  listener: (result: FTRemoteConfigResult) => void,
): EmitterSubscription;

Example

FTMobileReactNative.addRemoteConfigListener((result) => {
  console.log('Automatic remote configuration update result:', result);
});

Proactively Sync Dynamic Configuration

Use FTMobileReactNative to proactively sync dynamic configuration. When automatic updates do not meet requirements, you can adjust the update timing by proactively calling this method.

/**
 * Proactively updates remote configuration. The call frequency is affected by FTMobileConfig.remoteConfigMiniUpdateInterval.
 */
updateRemoteConfig(): Promise<FTRemoteConfigResult>;

/**
 * Proactively updates remote configuration, ignoring the global minimum update interval configuration.
 * If the time since the last update is less than the specified interval, the update operation will not be performed.
 * @param interval Minimum update interval, unit: seconds
 * @param rules Remote configuration override rules
 */
updateRemoteConfigWithMiniUpdateInterval(
  interval: number,
  rules?: Array<FTRemoteConfigOverrideRule>,
): Promise<FTRemoteConfigResult>;

Usage Example

// Basic proactive sync update (subject to global minimum interval limit)
FTMobileReactNative.updateRemoteConfig();

const rule: FTRemoteConfigOverrideRule = {
  id: 'test_rule',
  match: {
    customKeys: {
      custom_key: 'custom_value',
      vip_user_id: {
        contains: 'test_user_1001',
      },
    },
  },
  override: {
    rumSampleRate: 1,
    traceSampleRate: 1,
    logSampleRate: 1,
    logLevelFilters: ['info', 'warn'],
  },
};

const result = await FTMobileReactNative.updateRemoteConfigWithMiniUpdateInterval(0, [rule]);
console.log('updateRemoteConfigWithMiniUpdateInterval result ', result);

FTMobileReactNative.updateRemoteConfigWithMiniUpdateInterval(0, null);

When the value of customKeys is a plain value, it is treated as an exact match. When the value is { contains: value }, it is treated as a contains match.

contains is primarily suitable for matching specific users by a fixed key, such as vip_user_id. It will match if the corresponding field from the server returns any of the following formats:

  • A single string, e.g., "test_user_1001"
  • A JSON array, e.g., ["test_user_1001", "test_user_1002"]
  • A JSON string array, e.g., "[\"test_user_1001\",\"test_user_1002\"]"