Initialization
To create a VWO Client instance, you need to initialize the VWO FME iOS SDK. This client instance serves as the core interface for conducting feature management and experimentation(A/B and personalization) within your application.
Usage
import VWO_FME
// Set SDK Key and Account ID
let options = VWOInitOptions(accountId: ACCOUNT_ID, sdkKey: SDK_KEY)
// Initialize VWO SDK
VWOFme.initialize(options: options) { result in
switch result {
case .success(let message):
// VWO SDK initialized
case .failure(let error):
// VWO SDK failed to initialize
}
}
The initialize()
function is called with the sdkKey
and accountId
. It initializes and returns a VWO Client ObjectvwoClient
, which can be used to perform feature
This client object allows you to run experiments, track events, and enable/disable feature flags.
Parameter Definitions
Parameter | Type | Description |
---|---|---|
accountId Required | Int | Your VWO application's Account ID. |
sdkKey Required | String | A unique environment key is provided to you inside the Websites & Apps section in the VWO application, under Default Project. |
logLevel Optional | Enum | The level of logging to be used. For more details, please check - Logger |
logPrefix Optional | String | A prefix to be added to log messages. For more details, please check - Logger |
integrations Optional | IntegrationCallback | A callback function that receives data which can be pushed to any external tool that you need to integrate with. For more details, please check - Integrations |
cachedSettingsExpiryTime Optional | Int64 | Expiry time for cached settings in milliseconds. For more details, please check - Cache Management |
pollInterval Optional | Int64 | Time (in milliseconds) at which VWO should check with the server for any updates to the feature flag or rules in the VWO Dashboard. Useful to keep your VWO Client instance up-to-date with any changes made in the VWO Application. For more details, please check -Polling |
batchMinSize Optional | Int | Minimum size of batch to upload. For more detail, please check - Event Batching |
batchUploadTimeInterval Optional | Int64 | Batch upload time interval in milliseconds. For more detail, please check - Event Batching |
logTransport Optional | LogTransport | Protocol to send logs to external systems. For more details, please check - Logger |
Integrations
VWO SDKs help you integrate with several third-party destinations. SDKs help you integrate with any kind of tool, be it analytics, monitoring, customer data platforms, messaging, etc. by implementing a very basic and generic callback that is capable of receiving VWO-specific properties.
Example usage:
class MyClass: IntegrationCallback {
func execute(_ properties: [String: Any]) {
// Handle the integration callback here
print("Integration callback executed with properties: \(properties)")
}
}
// Create an instance of your class
let integrationClass = MyClass()
let options = VWOInitOptions(sdkKey: SDK_KEY, accountId: ACCOUNT_ID, integrations: integrationClass)
See Integrations documentation for additional information.
Log Transport
You can implement the LogTransport
protocol to customize how logs are handled and sent to external systems
Example usage:
// Define a class that conforms to the LogTransport protocol
class MyClass: LogTransport {
// Implement the log method to handle log messages
func log(logType: String, message: String) {
// Send log to a third-party service or handle it as needed
print("Log Type: \(logType), Message: \(message)")
}
}
// Create an instance of your class
let logClass = MyClass()
// Initialize VWOInitOptions with the custom log transport
let options = VWOInitOptions(sdkKey: SDK_KEY, accountId: ACCOUNT_ID, logTransport:logClass)
See Logging documentation for additional information.
Polling Interval Adjustment
The pollInterval
is an optional parameter that allows the SDK to automatically fetch and update settings from the VWO server at specified intervals. Setting this parameter ensures your application always uses the latest configuration.
Example usage:
// Initialize VWOInitOptions with a custom polling interval in milliseconds
let options = VWOInitOptions(sdkKey: SDK_KEY, accountId: ACCOUNT_ID, pollInterval:600000)
See Polling documentation for additional information.
Cached Settings Expiry Time
The cachedSettingsExpiryTime
parameter allows you to specify how long the cached settings should be considered valid before fetching new settings from the VWO server. This helps in managing the freshness of the configuration data.
Example usage:
// Initialize VWOInitOptions with a custom cached settings expiry time
let options = VWOInitOptions(sdkKey: SDK_KEY, accountId: ACCOUNT_ID, cachedSettingsExpiryTime:600000)
Event Batching Configuration
The VWO SDK supports storing impression events while the device is offline, ensuring no data loss. These events are batched and seamlessly synchronized with VWO servers once the device reconnects to the internet. Additionally, online event batching allows synchronization of impression events while the device is online. This feature can be configured by setting either the minimum batch size or the batch upload time interval during SDK initialization.
NOTE: The uploading of events will get triggered based on whichever condition is met first if using both options.
See Event Batching documentation for additional information.
Parameter | Description | Required | Type | Example |
---|---|---|---|---|
batchMinSize | Minimum size of the batch to upload. | No | Int | 10 |
batchUploadTimeInterval | Batch upload time interval in milliseconds. Please specify at least a few minutes. | No | Int64 | 300000 |
Example usage:
// Initialize VWOInitOptions with batch configuration
let options = VWOInitOptions(sdkKey: SDK_KEY, accountId: ACCOUNT_ID, batchMinSize:10, batchUploadTimeInterval: 300000)
Updated 21 days ago