Initialization

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

Usage

import { init } from 'vwo-fme-react-native-sdk';

import {
  VWOInitOptions,
  VWOContext,
  GetFlagResult,
} from 'vwo-fme-react-native-sdk/src/types';

let vwoClient;;

// initialize sdk
useEffect(() => {

    const initializeSDK = async () => {
      const options: VWOInitOptions = { sdkKey: SDK_KEY, accountId: ACCOUNT_ID };
      try {
        vwoClient = await init(options);
        console.log('VWO init success');
      } catch (error) {
        console.error('Error initialising', error);
      }
    };
    
    initializeSDK();
}, []);

As shown above, you need to first initialize the SDK, and set the SDK key and Account ID into options, after which you must call the RNVwo.initialize function with options 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 (accountId and sdkKey), there are some additional optional parameters that can be set using functions on vwInitOptions:

ParameterTypeDescription
accountId
Required
NumberYour VWO application's Account ID.
sdkKey
Required
StringUnique environment key provided to you inside the Websites & Apps section in VWO application.
pollInterval
Optional
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
logLevel
Optional
NumberDefines the level of logging. Default is ERROR. Options are DEBUG, INFO Logger
integrations
Optional
BooleanSet to true if there is an integration callback connected later.
Integration callback is a function that receives campaign data which can be pushed to any external tool that you need to integrate with. Integrations
gatewayService
Optional
ObjectDeclare details of the Gateway service
{url : gateway_url}

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 your SDK with the latest settings from VWO. This can be done via polling.