Skip to content

Feature Flags (Feature Vector Policy)

SAP Mobile Services allows you to configure feature flags using the SAP mobile service cockpit, as described in Feature Restrictions Overview. SAP Mobile Services maintains the list of enabled and restricted features and the iOS SDK reads these configurations from the application. Note that in the SAP mobile service cockpit this feature is called “feature restrictions policy”, while for the SDK it is called “feature vector policy.” You can manage the feature restriction policy using the Get Feature Restriction Policy Request API. See Managing Feature Restrictions for detailed information.

Managing Feature Flags in the SDK

The SDK stores the value of feature vector policies during an onboarding or restoring flow. The SDK deserializes the incoming JSON as an SAPcpmsFeatureVectorPolicy object and reads the policy as an SAPcpmsFeature.

You can retrieve the value of the feature vector policy from the onboarding context. The info dictionary of the onboarding context holds the value of featureVectorPolicy under sapcpmsFeatureVectorPolicies OnboardingInfoKey.

To retrieve these policies on a client application, you can use something similar to the following code:

guard let featureVectorPolicy = context.info[OnboardingInfoKey.sapcpmsFeatureVectorPolicies] as? SAPcpmsFeatureVectorPolicy else {
     return
}
let enabledAllFeatureVectorPolicy = featureVectorPolicy.featureVectorPolicyAllEnabled
let allowedPolicies = featureVectorPolicy.allowedPolicies
let restrictedPolicies = featureVectorPolicy.restrictedPolicies

Last update: February 20, 2023