Quick-start
Installation
You will find all instructions in installation topic
Flagship Usage
Start SDK
The first call you should make is to start the SDK by calling start
method through the Flagship singleton.
import Flagship
// Step 1 - Start the Flagship sdk with default configuration.
Flagship.sharedInstance.start(envId: "_ENV_ID_", apiKey: "_API_KEY_")
In step 1 The SDK needs to start the environmentId
and apiKey
. By default the Flagship start with Decision Mode
for more details on custom configuration go to Advanced Configuration.
Create Visitor
The second step after starting the SDK is visitor creation. This object allows you to manage visitor's context, experiments, and track events.
// Step 2 - Create visitor with context "isVip" : true
let visitor = Flagship.sharedInstance.newVisitor(visitorId: "visitorId", hasConsented: true)
.withContext(context: ["isVip": true])
.build()
In Step 2 We create a visitor providing his consent and his context. Go to builder methods to learn more about visitor creation.
Getting flags
Once we have created our visitor instance we need to fetch flags. Go to Flag to learn more about.
// Step 3 - Fetch flags
visitor.fetchFlags {
// Fetch completed
// Step 4 - Get Flag key
let flag = visitor.getFlag(key: "flagKey")
// Step 5 - Read Flag value
let value = flag.value(defaultValue: "defaultValue")
}
When flag fetching completes in step 3 its inner code block is executed. In step 4, we are ready to process visitor's flags and read their values in step 5.
Note: SDK will report exposition by default when reading a Flag value.
Tracking hits
Then sending events tracking will allows you to validate objectives in your campaign reporting.
// Step 6 - Send Event
visitor.sendHit(FSEvent(eventCategory: .Action_Tracking, eventAction: "event_action"))
In step 6 Flagship is on charge of sending the event_action event through the function sendHit
. Go to tracking for more information.
You should see your hit using hitStream feature, then on your campaign report.
Last updated
Was this helpful?