Migration to v4.X
This guide will assist developers to move from Flagship 3.X to Flagship 4.X.
The main breaking changes are:
Consent Management
Visitor Status
See the full change log on Github.
Consent Management
The version 4.X introduces a required consent parameter when creating a Visitor instance:
public func newVisitor(visitorId: String, hasConsented: Bool, instanceType: Instance = .SHARED_INSTANCE) -> FSVisitorBuilder
// 1- In the version 4.X we added a label for visitorId parameter and introduce required consent parameter.
// 2- Remove from the builder .hasConsented function.
let visitor1 = Flagship.sharedInstance.newVisitor(visitorId:"userId", hasConsented:true)
.withContext(context: ["isVip":true])
.isAuthenticated(true)
.build()import Flagship
// When omitted default consent value was true.
let visitor1 = Flagship.sharedInstance.newVisitor("visitor_1")
.withContext(context: ["age" : 32, "isVip":true])
.isAuthenticated(true)
.hasConsented(hasConsented: true)
.build()Flagship SDK Status
Status Listener
The withStatusListener renamed to withOnSdkStatusChangedand the type of parameter fromFStatustoFSSdkStatus_
func withOnSdkStatusChanged(_ onSdkStatusChanged: @escaping (_ newStatus: FSSdkStatus)->Void)->FSConfigBuilder
Get Status
Status Values
SDK_NOT_INITIALIZED
The SDK has not been started
SDK_INITIALIZING
The SDK still starting, in bucketing mode the sdk needs to download the ressources (bucketing file) before start. if the file exist already this status is skipped
SDK_INITIALIZED
The SDK is ready to use.
SDK_PANIC
The SDK is ready but is running in Panic mode: All visitor's features are disabled except 'fetchFlags' which refreshes this status.
Flag
The defaultValue in 4.X is provided at the reading value method through the flag instance and not as 3.X which is provided at getFlag method.
Get Flag
You can retrieve Flag by using the following functions from the Visitor instance:
func getFlag(key:String)->FSFlag
Reading Flag Value
To read the current flag's value, simply call value() method of the Flag object.
func value<T>(defaultValue:T?,visitorExposed: Bool = true)->T?
Last updated
Was this helpful?

