Feature Flag Setup¶
A Feature Flag is a statement in your code that specifies how the app should behave when the flag is “on” or “off”. This logic can be used multiple times in your code.
if (Apptimize.isFeatureFlagOn("new_feature_flag_variable")) {
// ON
} else {
// OFF
}
val userId = "1234abcd";
if (Apptimize.isFeatureFlagEnabled("new_feature_flag_variable", userId)) {
// ON
} else {
// OFF
}
if ([Apptimize isFeatureFlagOn:@"new_feature_flag_variable"]) {
// ON
} else {
// OFF
}
if (Apptimize.isFeatureFlag(on: "new_feature_flag_variable")) {
// ON
} else {
// OFF
}
if (Apptimize.isFeatureFlagEnabled("new_feature_flag_variable")) {
// ON
} else {
// OFF
}
var userId = "1234abcd";
if (Apptimize.isFeatureFlagEnabled("new_feature_flag_variable", userId)) {
// ON
} else {
// OFF
}
userId = "1234abcd"
if Apptimize.isFeatureFlagEnabled("new_feature_flag_variable", userId):
# ON
else:
# OFF
curl -X GET \
-H "ApptimizeApiToken: <ApiToken>" \
https://api.apptimize.com/v1/users/1234abcd/feature-flags/new_feature_flag_variable
userId = "1234abcd"
m.requestId = m.apptimize.callFunc("isFeatureFlagEnabled", {userid: userId, name: "new_feature_flag_variable", customAttributes: {}})
' Requires setup of setcontent callback as described in Roku installation steps
function setcontent(message as object)
apptimizeResponse = message.getData()
if (apptimizeResponse.id = m.requestId) then
?"Feature Flag: ";apptimizeResponse.response.isFeatureFlagEnabled
end if
end function
The variable name used (new_feature_flag_variable
in the example above)
should match the variable name within the “Create Code” tab of your feature flag. This
links the Feature Flag in the Apptimize dashboard to your app’s code. We recommend using
the “Create Code” option to generate the snippet you will use to avoid errors.