Initialization

Initialize an instance of VWO which will then be used to manage all feature flags and rules. This vwoInstance instance contains all the feature flags and rules that you have configured in your VWO dashboard.

Usage

import com.vwo.VWO
import com.vwo.interfaces.IVwoInitCallback
import com.vwo.models.user.VWOContext
import com.vwo.models.user.VWOInitOptions

// Set SDK Key and Account ID
val vwoInitOptions = VWOInitOptions()
vwoInitOptions.sdkKey = SDK_KEY
vwoInitOptions.accountId = ACCOUNT_ID

// Initialize VWO SDK
VWO.init(vwoInitOptions, object : IVwoInitCallback {
    override fun vwoInitSuccess(vwo: VWO, message: String) {
        // VWO SDK initialized
    }
 
    override fun vwoInitFailed(message: String) {
        // VWO SDK failed to initialize
    }
})
import com.vwo.VWO;
import com.vwo.interfaces.IVwoInitCallback;
import com.vwo.models.user.VWOContext;
import com.vwo.models.user.VWOInitOptions;

// Set SDK Key and Account ID
VWOInitOptions vwoInitOptions = new VWOInitOptions();
vwoInitOptions.setSdkKey(SDK_KEY);
vwoInitOptions.setAccountId(ACCOUNT_ID);

// Initialize VWO SDK
VWO.init(vwoInitOptions, new IVwoInitCallback() {
    @Override
    public void vwoInitSuccess(@NonNull VWO vwo, @NonNull String message) {
        // VWO SDK Initialized  
    }
 
    @Override
    public void vwoInitFailed(@NonNull String message) {
        // VWO SDK failed to initialize
    }
});

As shown above, you need to first initialize the SDK, and set the SDK key and Account ID into vwoInitOptions, after which you must call the VWO.init() function with _vwoInitOptions as an argument.

VWOInitOptions can be used to set additional parameters, of which two are mandatory:

  1. accountId: This is the unique VWO account ID which you can find on your VWO Dashboard.
  1. sdkKey: A unique 32-character string corresponding to the project/environment in VWO. You will find this in the Websites & Apps section in VWO, under a "Default Project" for FME.

Parameter Definitions

Besides the two mandatory parameters (accountd and sdkKey), there are some additional optional parameters that can be set:

ParameterUsageTypeDescription
accountId
Required
vwoInitOptions.setAccountId(123);NumberYour VWO application's Account ID.
sdkKey
Required
vwoInitOptions.setSdkKey("sdk-key");StringUnique environment key provided to you inside the Websites & Apps section in VWO application.
pollInterval
Optional
vwoInitOptions.setPollInterval(60);NumberTime period (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 vwoClient instance up to date with any changes made in the VWO Application. Polling
logger
Optional
vwoInitOptions.setLogger(logger);ObjectAn optional logger object that defines the logging behaviour. Logger
integrations
Optional
vwoInitOptions.setIntegrations(integrations);ObjectContains a callback function that receives campaign data which can be pushed to any external tool that you need to integrate with. Integrations

Keeping vwoClient up-to-date

When you initialize the VWO SDK in your mobile application, it pulls the latest configurations you've done in the VWO application.
If/when you make any changes to the feature flags or rules within VWO after the SDK has been initialized in your application, there needs to be some way to update VWO SDK client with the latest settings from VWO. This can be done via polling.