In this article:
- Summary
- Optionally Persisting Winning Variants & Instant Updates
- Getting the Variant ID's
- iOS API
- Android API
- Changing Log Level for Troubleshooting
Summary
The forceVariant API provide you with a programmatic way to force certain variants to your mobile device using the variant id.
Once forceVariant is called, Apptimize is placed in a special test mode where it will only enable variants that are forced by forceVariant. By default all other Feature Flags, A/B Experiments and Instant Updates will appear disabled/off unless a specific variant is forced for those projects. You need to call forceVariant for each of the variants you want to apply. So, if you have 3 experiments and you want to see how the variants from all 3 interact with each other, you must call the forceVariant API for one of the variants from all 3 experiments.
Note: The Preview Variant tool on the dashboard will not work when there are forced variant(s) on a paired device. This is because Preview Variant works by sending an instant update to the paired device.
Optionally Persisting Winning Variants & Instant Updates
As of version 3.1.16 of our iOS SDK (changelog) and version 3.4.12 of our Android SDK (changelog), we now allow for you to optionally initialize Apptimize with an “ApptimizeOption” which will cause Winning Variants and Instant Updates to persist through even after forceVariant is invoked.
See our iOS and Android SDK documentation for additional details.
Getting the Variant ID's
There are 2 ways to get the Variant ID
- You can use the getVariants API (iOS and Android) to retrieve the information about all the variants of the currently active projects.
- Alternatively, you can view the id for a specific variant in the experiment configuration in the configure step or in the results, next to the variant name.
Note that if you do not see the Variant ID's in the dashboard, you can enable the feature in your ‘Organization Details’ view, by checking the ‘Display Variant Id’ option in the detail view of the app.
iOS API
(void)forceVariant:(NSInteger)variantID
Force the variant with the given ID to be enabled. Filter logic is ignored. No other experiments or instant updates through regular means will be applied if a variant is forced.
If called multiple times, the set of variantIDs that are set via forceVariant are all forced. If an ID is invalid it does nothing, but other experiments / instant updates are still off.
(void)clearForcedVariant:(NSInteger)variantID
Disables the variant with the given ID. Does nothing if the variant is not forced.
Disables all variants which were forced by the forceVariant call.
Android API
public static void forceVariant(long variantID)
Force the variant with the given ID to be enabled. Filter logic is ignored. No other experiments or instant updates through regular means will be applied if a variant is forced.
If called multiple times, the set of variantIDs that are set via forceVariant are all forced. If an ID is invalid it does nothing, but other experiments / instant updates are still off.
public static void clearForcedVariant(long variantID)
Disables the variant with the given ID. Does nothing if the variant is not forced.
public static void clearAllForcedVariants()
Disables all variants which were forced by the forceVariant call.
Changing Log Level for Troubleshooting
You have the option of controlling the verbosity of Apptimize logs, using the Log Level option. This option can be configured during the Apptimize setup call to get detailed logs that can be useful for troubleshooting. Click the links below for more detail.
iOS API
Note that in iOS, this option can also be set in the plist using the property ApptimizeLogLevel.
Comments
0 comments
Please sign in to leave a comment.