GuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityLog In

Get Enabled Features

Retrieves a list of features that are enabled for the user. Invoking this method is equivalent to running Is Feature Enabled for each feature in the datafile sequentially.

This method takes into account the user attributes passed in, to determine if the user is part of the audience that qualifies for the experiment.

Version

SDK v3.1.0

Description

This method iterates through all feature flags and for each feature flag invokes Is Feature Enabled. If a feature is enabled, this method adds the feature’s key to the return list.

Parameters

The table below lists the required and optional parameters in Swift.

Parameter

Type

Description

userId
required

String

The ID of the user to check.

attributes
optional

Dictionary<String, Any>

A map of custom key-value string pairs specifying attributes for the user that are used for audience targeting. Non-string values are only supported in the 3.0 SDK and above.

Returns

A list of keys corresponding to the features that are enabled for the user, or an empty list if no features could be found for the specified user.

Examples

This section shows a simple example of how you can use the method.

let attributes = [
  "device": "iPhone",
  "lifetime": 24738388,
  "is_logged_in": true,
]

let enabledFeatures = optimizely.getEnabledFeatures(userId: "user_123", attributes: attributes)
NSDictionary *attributes = @{
  @"device": @"iPhone",
  @"lifetime": @24738388,
  @"is_logged_in": @true
};

NSArray *enabledFeatures = [optimizely getEnabledFeaturesWithUserId:@"user_123"
                                                    attributes:attributes];

Source files

The language/platform source files containing the implementation for Swift is OptimizelyClient.swift.


Did this page help you?