Quick-start

Installation

Refer to the installation page for installation steps.

Getting started

Below is a simple example that describes the instantiation of the ABTasty Provider. Please see the OpenFeature Documentation for details on how to use the OpenFeature SDK.

Add the following to your Package.swift:

dependencies: [
    .package(url: "https://github.com/flagship-io/openfeature-provider-iOS.git", from: "1.0.0")
]

Import the required modules:

import ABTastyOpenfeature_iOS
import OpenFeature

Register the ABTastyProvider with OpenFeature

Init and Set provider with context

In the context use the targetingKey for the visitorId and you should mention hasConsented through the context

 
 // Create a context with an "openUserId"
 let ctx = MutableContext(
            targetingKey: "openUserId",
            structure: MutableStructure(attributes: ["isQA": Value.boolean(true),
                                                     "city": Value.string("FR"),
                                                     "hasConsented": Value.boolean(true),
                                                     "ctx1": Value.boolean(false),
                                                     "ctx2": Value.integer(125),
                                                     "ctx3": Value.double(12.0)])
                                                     
Task {
    // Create ABTasty provider
   let provider = ABTastyProvider(envId: "envId", apiKey: "apiKey", configurator: FSConfigBuilder().build())
   // Set provider through OpenFeature API
   await OpenFeatureAPI.shared.setProviderAndWait(provider: provider, initialContext: ctx)
}

Flag Evaluation (Read Flag)

After init and set provider with the apropriate context use the client instance to get the evaluation flag

Context Updates

On visitor context changed use setEvaluationContextAndWait function before read flag value

Last updated

Was this helpful?