OptimizelyPlugin Protocol Reference

Conforms to NSObject
Declared in OptimizelyPlugin.h

Overview

This protocol must be implemented by classes which wish to integrate with Optimizely via the Plugin System. For more information on creating a plugin see our documentation:

  pluginId required method

Each plugin must have a unique identifier. The bundle name of the plugin is usually sufficient. For example: ‘com.optimizely.crashreporting’ This property will be queried after the plugin initialization but before start is called.

@property (nonatomic, strong) NSString *pluginId

Declared In

OptimizelyPlugin.h

– getDependencies required method

Declare all dependencies on other plugins here. This selector will be queried before start is called, but after initialization.

- (NSSet *)getDependencies

Return Value

a list of plugin identifiers

Declared In

OptimizelyPlugin.h

– shouldHandleTouchEvents required method

true if this plugin should receive and handle touch events. This selector will be queried after start has been called.

- (BOOL)shouldHandleTouchEvents

Return Value

true if this plugin should receive and handle touch events. This selector will be queried after start has been called.

Declared In

OptimizelyPlugin.h

– startWithOptimizely:withConfig: required method

Initialize the plugin and start any listeners or threads.

- (BOOL)startWithOptimizely:(Optimizely *)optimizely withConfig:(NSDictionary *)config

Parameters

optimizely

A reference to the Optimizely singleton so that services can be accessed

config

The config object for this plugin from the data file

Return Value

true if the plugin was started successfully, false otherwise.

Declared In

OptimizelyPlugin.h

– stop required method

Stop the extension and clean up any objects that are owned by the extension.

- (void)stop

Declared In

OptimizelyPlugin.h

– getLiveVariables

Declare all LiveVariable keys that this plugin wishes to modify. This selector will be queried after start has been called. May return nil if this plugin does not modify live variables.

- (NSSet *)getLiveVariables

Return Value

a set of strings which correspond to the LiveVariable key names.

Declared In

OptimizelyPlugin.h

– getCodeBlocks

Declare all CodeBlock keys that this plugin wishes to modify. This selector will be queried after start has been called. May return nil if this plugin does not modify code blocks.

- (NSSet *)getCodeBlocks

Return Value

a set of strings which correspond to the CodeBlock key names.

Declared In

OptimizelyPlugin.h

– evaluateLiveVariableOfType:forKey:defaultValue:

Evaluate the given live variable and return the value. The value must be of the type denoted by cls. The default value should be returned if the plugin does not care

- (id)evaluateLiveVariableOfType:(Class)cls forKey:(NSString *)key defaultValue:(id)defaultValue

Parameters

cls

the class of the expected type

key

the name of the live variable

defaultValue

the default value for the live variable

Return Value

the calculated value for the live variable

Declared In

OptimizelyPlugin.h

– evaluateCodeBlockForKey:

Evaluate the given code block and return the name of the branch that should be executed. Nil may be returned if the plugin does not care.

- (NSString *)evaluateCodeBlockForKey:(NSString *)key

Parameters

key

the name of the code block

Return Value

the name of the branch to execute.

Declared In

OptimizelyPlugin.h

– processTouchEvent:

If shouldHandleTouchEvents returns true, touch events will be passed to the plugin. This selector will be queried after start has been called.

- (void)processTouchEvent:(UIEvent *)event

Parameters

event

The event that the plugin will process

Declared In

OptimizelyPlugin.h

– dimensionNames

Declare the dimension names that this plugin handles.

- (NSSet *)dimensionNames

Return Value

nil or a NSSet of dimension names

Declared In

OptimizelyPlugin.h

– evaluateDimension:withCondition:

Evaluate a dimension name against it’s condition.

- (BOOL)evaluateDimension:(NSString *)dimensionName withCondition:(NSDictionary *)condition

Parameters

dimensionName

name of the condition to evaluate. Useful for switching on the different dimension names supported by this plugin.

condition

NSDictionary containing key value pairs used by the Optimizely dimension evaluator, i.e.: { “name: "skymosity.currentTemperature”, “value”: “10:60”, “match_type”: “range”, “content_type” : “third_party_dimension” }

Return Value

true if the condition passes for the given dimension name and false if it doesn’t.

Declared In

OptimizelyPlugin.h