Apptimize Class Reference

Inherits from NSObject
Declared in Apptimize.h

Other Methods

+ startApptimizeWithApplicationKey:

Start Apptimize with the default options.

+ (void)startApptimizeWithApplicationKey:(NSString *)applicationKey

Discussion

Start Apptimize with the default options.

Declared In

Apptimize.h

+ startApptimizeWithApplicationKey:options:

Start Apptimize with the provided options, where options is nil or a dictionary containing some combination of ApptimizeDevicePairingOption, ApptimizeLogLevelOption, ApptimizeDelayUntilTestsAreAvailableOption, ApptimizeEnableThirdPartyEventImportingOption, ApptimizeEnableThirdPartyEventExportingOption, ApptimizeEnableInteractionEventCollectionOption, and their respective values.

+ (void)startApptimizeWithApplicationKey:(NSString *)applicationKey options:(NSDictionary *)options

Discussion

Start Apptimize with the provided options, where options is nil or a dictionary containing some combination of ApptimizeDevicePairingOption, ApptimizeLogLevelOption, ApptimizeDelayUntilTestsAreAvailableOption, ApptimizeEnableThirdPartyEventImportingOption, ApptimizeEnableThirdPartyEventExportingOption, ApptimizeEnableInteractionEventCollectionOption, and their respective values.

Apptimize should be started on the main thread and can be safely started more than once.

Declared In

Apptimize.h

+ disable

Disable Apptimize and all of its features for one application session. No tests will run, no data will be logged, and no results will be posted to the Apptimize dashboard. Use with caution.

+ (void)disable

Discussion

Disable Apptimize and all of its features for one application session. No tests will run, no data will be logged, and no results will be posted to the Apptimize dashboard. Use with caution.

Declared In

Apptimize.h

+ setOffline:

Optionally run in offline mode. In offline mode, all network traffic is disabled. Specifically, the app will not receive metadata, upload results, or (for debug builds) be able to pair with the Apptimize web dashboard.

+ (void)setOffline:(BOOL)offlineFlag

Discussion

Optionally run in offline mode. In offline mode, all network traffic is disabled. Specifically, the app will not receive metadata, upload results, or (for debug builds) be able to pair with the Apptimize web dashboard.

This setting is persistent and stays in effect between sessions.

You may call setOffline before calling [Apptimize startApptimizeWithApplicationKey].

Declared In

Apptimize.h

+ isOffline

Get the current value of the offline setting
+ (BOOL)isOffline

Discussion

Get the current value of the offline setting

Declared In

Apptimize.h

+ isFeatureFlagOn:

Returns YES if and only if the feature flag is on.

+ (BOOL)isFeatureFlagOn:(NSString *)featureFlagName

Return Value

Returns YES if and only if the feature flag is on.

Declared In

Apptimize.h

+ runTest:withBaseline:variations:andOptions:

Run a test. Either the baseline or one of the variation blocks will be called synchronously exactly once per call. To run a test, set it up at https://apptimize.com/admin/ and then copy and paste the provided code template into your code to use this. Options should be nil or a dictionary containing ApptimizeUpdateMetadataTimeoutOption and a value in milliseconds. For Swift use: runTest:withBaseline:codeBlocks:andOptions:

+ (void)runTest:(NSString *)testName withBaseline:(void ( ^ ) ( void ))baselineBlock variations:(NSDictionary *)variations andOptions:(NSDictionary *)options

Discussion

Run a test. Either the baseline or one of the variation blocks will be called synchronously exactly once per call. To run a test, set it up at https://apptimize.com/admin/ and then copy and paste the provided code template into your code to use this. Options should be nil or a dictionary containing ApptimizeUpdateMetadataTimeoutOption and a value in milliseconds. For Swift use: runTest:withBaseline:codeBlocks:andOptions:

Declared In

Apptimize.h

+ runTest:withBaseline:andVariations:

Same as runTest:withBaseline:variations:andOptions: passing nil for options. For Swift use: runTest:withBaseline:andCodeBlocks:

+ (void)runTest:(NSString *)testName withBaseline:(void ( ^ ) ( void ))baselineBlock andVariations:(NSDictionary *)variations

Discussion

Same as runTest:withBaseline:variations:andOptions: passing nil for options. For Swift use: runTest:withBaseline:andCodeBlocks:

Declared In

Apptimize.h

+ runTest:withBaseline:apptimizeCodeBlocks:andOptions:

Same as runTest:withBaseline:variations:andOptions: except takes an array of ApptimizeCodeBlock. This is useful in Swift where using runTest:withBaseline:variations:andOptions: is problematic because of bridging issues.

+ (void)runTest:(NSString *)testName withBaseline:(void ( ^ ) ( void ))baselineBlock apptimizeCodeBlocks:(NSArray *)codeBlocks andOptions:(NSDictionary *)options

Discussion

Same as runTest:withBaseline:variations:andOptions: except takes an array of ApptimizeCodeBlock. This is useful in Swift where using runTest:withBaseline:variations:andOptions: is problematic because of bridging issues.

Declared In

Apptimize.h

+ runTest:withBaseline:andApptimizeCodeBlocks:

Same as runTest:withBaseline:codeBlocks:andOptions: passing nil for options.

+ (void)runTest:(NSString *)testName withBaseline:(void ( ^ ) ( void ))baselineBlock andApptimizeCodeBlocks:(NSArray *)codeBlocks

Discussion

Same as runTest:withBaseline:codeBlocks:andOptions: passing nil for options.

Declared In

Apptimize.h

+ track:

Track an event

+ (void)track:(NSString *)eventName

Discussion

Track an event

Declared In

Apptimize.h

+ track:value:

Track an event with an associated numeric value.

+ (void)track:(NSString *)eventName value:(double)value

Discussion

Track an event with an associated numeric value.

Declared In

Apptimize.h

+ setLogLevel:

Set the log level of the Apptimize library.

+ (void)setLogLevel:(NSString *)logLevel

Discussion

Set the log level of the Apptimize library.

Declared In

Apptimize.h

+ libraryVersion

Returns the version number of the Apptimize library in this form: major.minor.build (e.g., 1.2.0)

+ (NSString *)libraryVersion

Return Value

Returns the version number of the Apptimize library in this form: major.minor.build (e.g., 1.2.0)

Declared In

Apptimize.h

+ userID

Returns the ID used by Apptimize to uniquely identify users of the current app

+ (NSString *)userID

Return Value

Returns the ID used by Apptimize to uniquely identify users of the current app

Declared In

Apptimize.h

+ setPilotTargetingID:

Set the pilotTargetingID if you want to use the pilot targeting feature available on your Apptimize web dashboard. Pilot targeting allows you to select specific pilotTargingID’s and groups of pilotTargetingID’s in the Apptimize web dashboard for the purposes of targeting experiments and feature flags to specific app/user instances. Setting this value will cause pilot targeting to be recalculated if applicable.

+ (void)setPilotTargetingID:(NSString *)pilotTargetingID

Discussion

Set the pilotTargetingID if you want to use the pilot targeting feature available on your Apptimize web dashboard. Pilot targeting allows you to select specific pilotTargingID’s and groups of pilotTargetingID’s in the Apptimize web dashboard for the purposes of targeting experiments and feature flags to specific app/user instances. Setting this value will cause pilot targeting to be recalculated if applicable.

Declared In

Apptimize.h

+ pilotTargetingID

Returns the pilotTargetingID. By default this value is nil. It should be set by your application to enable pilot targeting for the device. Pilot targeting allows you to select specific pilotTargingID’s and groups of pilotTargetingID’s in the Apptimize web dashboard for the purposes of targeting experiments and feature flags to specific app/user instances. Setting this value will cause pilot targeting to be recalculated if applicable.

+ (NSString *)pilotTargetingID

Return Value

Returns the pilotTargetingID. By default this value is nil. It should be set by your application to enable pilot targeting for the device. Pilot targeting allows you to select specific pilotTargingID’s and groups of pilotTargetingID’s in the Apptimize web dashboard for the purposes of targeting experiments and feature flags to specific app/user instances. Setting this value will cause pilot targeting to be recalculated if applicable.

Declared In

Apptimize.h

+ testInfo

Returns information about all Apptimize A/B tests and Feature Flags that the device is enrolled in. Note that this does NOT include information about Apptimize A/B tests or Feature Flags that are running but that the device is not enrolled in.

+ (NSDictionary *)testInfo

Return Value

The NSDictionary whose keys are the names of all A/B tests and Feature Flags the device is enrolled in, and whose values are ApptimizeTestInfo objects containing information about the test or feature flag. The return will be empty if this device is enrolled in no tests.

Returns nil if Apptimize::startApptimizeWithApplicationKey… has not been called.

Discussion

Returns information about all Apptimize A/B tests and Feature Flags that the device is enrolled in. Note that this does NOT include information about Apptimize A/B tests or Feature Flags that are running but that the device is not enrolled in.

Declared In

Apptimize.h

+ waitForTestsToBecomeAvailable:

Wait for the initial set of tests to become available. This method will block for timeout milliseconds (up to 8000) while Apptimize attempts to fetch tests and any related assets. It is meant to be used as part of application initialization, usually during a loading screen.

+ (BOOL)waitForTestsToBecomeAvailable:(NSTimeInterval)timeout

Discussion

Wait for the initial set of tests to become available. This method will block for timeout milliseconds (up to 8000) while Apptimize attempts to fetch tests and any related assets. It is meant to be used as part of application initialization, usually during a loading screen.

Declared In

Apptimize.h

Appboy Methods

+ apptimizeTrackAppboyEvent:

Do not call this method! This method is specifically for the Appboy SDK integration with the Apptimize SDK and should only be called by the Appboy SDK.

+ (void)apptimizeTrackAppboyEvent:(NSString *)eventName

Discussion

Do not call this method! This method is specifically for the Appboy SDK integration with the Apptimize SDK and should only be called by the Appboy SDK.

Declared In

Apptimize+Appboy.h

UserAttributes Methods

+ setUserAttributeString:forKey:

Set an NSString user attribute to be used for targeting, filtering and segmentation.

+ (void)setUserAttributeString:(NSString *)attributeValue forKey:(NSString *)attributeName

Discussion

Set an NSString user attribute to be used for targeting, filtering and segmentation.

Declared In

Apptimize.h

+ setUserAttributeInteger:forKey:

Set an NSInteger user attribute to be used in targeting, filtering and segmentation.

+ (void)setUserAttributeInteger:(NSInteger)attributeValue forKey:(NSString *)attributeName

Discussion

Set an NSInteger user attribute to be used in targeting, filtering and segmentation.

Declared In

Apptimize.h

+ setUserAttributeDouble:forKey:

Set a double user attribute to be used for targeting, filtering and segmentation.

+ (void)setUserAttributeDouble:(double)attributeValue forKey:(NSString *)attributeName

Discussion

Set a double user attribute to be used for targeting, filtering and segmentation.

Declared In

Apptimize.h

+ setUserAttributeBool:forKey:

Set a boolean user attribute to be used for targeting, filtering and segmentation.

+ (void)setUserAttributeBool:(BOOL)attributeValue forKey:(NSString *)attributeName

Discussion

Set a boolean user attribute to be used for targeting, filtering and segmentation.

Declared In

Apptimize.h

+ removeUserAttributeForKey:

Remove the user defined attribute for a given for key.

+ (void)removeUserAttributeForKey:(NSString *)attributeName

Discussion

Remove the user defined attribute for a given for key.

Declared In

Apptimize.h

+ removeAllUserAttributes

Remove all user defined attributes.

+ (void)removeAllUserAttributes

Discussion

Remove all user defined attributes.

Declared In

Apptimize.h

+ userAttributeStringForKey:

Get the currently set NSString user attribute for a given key.

+ (NSString *)userAttributeStringForKey:(NSString *)attributeName

Discussion

Get the currently set NSString user attribute for a given key.

Declared In

Apptimize.h

+ userAttributeIntegerForKey:

Get the current NSInteger user attribute for a given key.

+ (NSInteger)userAttributeIntegerForKey:(NSString *)attributeName

Discussion

Get the current NSInteger user attribute for a given key.

Declared In

Apptimize.h

+ userAttributeDoubleForKey:

Get the current double user attribute for a given key.

+ (double)userAttributeDoubleForKey:(NSString *)attributeName

Discussion

Get the current double user attribute for a given key.

Declared In

Apptimize.h

+ userAttributeBoolForKey:

Get the current boolean user attribute for a given key.

+ (BOOL)userAttributeBoolForKey:(NSString *)attributeName

Discussion

Get the current boolean user attribute for a given key.

Declared In

Apptimize.h

ViewAttributes Methods

+ setValue:forAttribute:onView:

Set an attribute on a view to a value. Apptimize will use these attributes to gather more information about views for visual editing.

+ (void)setValue:(NSString *)value forAttribute:(NSString *)attributeName onView:(UIView *)view

Discussion

Set an attribute on a view to a value. Apptimize will use these attributes to gather more information about views for visual editing.

Declared In

Apptimize.h

VariantOverrides Methods

+ forceVariant:

Force the variant with the given ID to be enabled.

+ (void)forceVariant:(NSInteger)variantID

Discussion

Force the variant with the given ID to be enabled.

Once +forceVariant is called, Apptimize is placed in a special test mode where it will only enable variants that are forced by +forceVariant. All other Feature Flags, A/B Experiments and Instant Updates will appear disabled/off unless a specific variant is forced for those projects. Call +forceVariant for each of the variants you want to apply.

Use +clearAllForcedVariants to return Apptimize to normal operation.

All variants forced using this method will be treated as though they underwent experiment selection, and will be reflected on your results dashboard. Forced variants are persistent across application launches and will not be reset except by calls to [Apptimize clearForcedVariant:] or [Apptimize clearAllForcedVariants].

Note that the “Advanced Verify” feature on the dashboard will not work when there are forced variant(s) on the paired device (because “Advanced Verify” works by sending an instant update to the paired device).

Declared In

Apptimize.h

+ clearForcedVariant:

Cancel a forced variant.

+ (void)clearForcedVariant:(NSInteger)variantID

Discussion

Cancel a forced variant.

Declared In

Apptimize.h

+ clearAllForcedVariants

Cancel all forced variants.

+ (void)clearAllForcedVariants

Discussion

Cancel all forced variants.

Declared In

Apptimize.h

+ getVariants

Get a dictionary of information about all available variants.

+ (NSDictionary *)getVariants

Discussion

Get a dictionary of information about all available variants.

The returned dictionary has keys of variantIDs as NSStrings. Each value is an NSDictionary with information about the variant: @{ @“variantName”: <NSString variant name>, @“variantID”: <NSNumber id>, @“experimentName”: <NSString experiment name>, @“experimentID”: <NSNumber id> @} The returned dictionary will be empty if there are no available variants.

Returns nil if Apptimize::startApptimizeWithApplicationKey… has not been called.

Declared In

Apptimize.h