.. _feature_flag_setup: 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. .. tabs:: .. code-tab:: java Android (Java) :caption: Android (Java) if (Apptimize.isFeatureFlagOn("new_feature_flag_variable")) { // ON } else { // OFF } .. code-tab:: kotlin Android (Kotlin) :caption: Android (Kotlin) val userId = "1234abcd"; if (Apptimize.isFeatureFlagEnabled("new_feature_flag_variable", userId)) { // ON } else { // OFF } .. code-tab:: objectivec iOS (Objective-C) :caption: iOS (Objective-C) if ([Apptimize isFeatureFlagOn:@"new_feature_flag_variable"]) { // ON } else { // OFF } .. code-tab:: swift iOS (Swift) :caption: iOS (Swift) if (Apptimize.isFeatureFlag(on: "new_feature_flag_variable")) { // ON } else { // OFF } .. code-tab:: javascript JavaScript :caption: JavaScript if (Apptimize.isFeatureFlagEnabled("new_feature_flag_variable")) { // ON } else { // OFF } .. code-tab:: js Node.js :caption: Node.js var userId = "1234abcd"; if (Apptimize.isFeatureFlagEnabled("new_feature_flag_variable", userId)) { // ON } else { // OFF } .. code-tab:: python Python :caption: Python 3 userId = "1234abcd" if Apptimize.isFeatureFlagEnabled("new_feature_flag_variable", userId): # ON else: # OFF .. code-tab:: bash Rest API :caption: Rest API curl -X GET \ -H "ApptimizeApiToken: " \ https://api.apptimize.com/v1/users/1234abcd/feature-flags/new_feature_flag_variable .. code-tab:: text Roku :caption: Roku 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 (:code:`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. .. image:: setup/create-feature-flag-all-platforms.png