Feature Flags for the React Native Module

A Feature Flag is an experimentation tool for controlling the availability of content or functionality in your app or website. A flag’s Configurations determine the audience, schedule, and property values to apply when the flag is enabled. Flag properties enable making immediate code updates, bypassing the need for traditional code changes and release processes. iOS SDK 17.1+Android SDK 17.1+

Accessing flags

The Airship SDK will refresh feature flags when the app is brought to the foreground. If a feature flag is accessed before the foreground refresh completes, or after the foreground refresh has failed, feature flags will be refreshed during flag access. Feature flags will only be updated once per session and will persist for the duration of each session.

Once defined in the dashboard, a feature flag can be accessed by its name in the SDK after takeOff.

const flag = await Airship.featureFlagManager.flag("YOUR_FLAG_NAME");
if (flag.isEligible) {
    // Do something with the flag
} else { 
    // Disable feature or use default behavior
}

Tracking interaction

To generate the Feature Flag Interaction Event, you must manually call trackInteraction with the feature flag. Analytics must be enabled. See: Data Collection: Privacy Manager.

await Airship.featureFlagManager.trackInteraction(flag);

Error handling

If a feature flag allows evaluation with stale data, the SDK evaluates the flag if a definition for the flag is found. Otherwise, feature flag evaluation depends on updated local state. If the SDK cannot evaluate a flag because data cannot be fetched, the SDK returns or raises an error. The app can either treat the error as the flag being ineligible or retry at a later time.

try {
    await Airship.featureFlagManager.flag("YOUR_FLAG_NAME");
} catch(error) {
    // Do something with the error
}