AbTesting¶
Scopely A/B testing client. It allows you to get the values for the variants this device is enrolled into.
Public methods¶
getInstance()¶
Initializes the AbTesting client.
getEnrollmentsValues()¶
Synchronously retrieves a dictionary of values for the variants this device
got enrolled and caches them for further use via getValue
methods.
This method throws a AbTestingException
if something went wrong.
This cannot be run in the UI-Thread or an exception will be thrown.
Example
Retrieves the value of the key label_msg
:
AbTesting abTesting = AbTesting.getInstance();
Map<String, String> dict = abTesting.getEnrollmentsValues();
String labelMsg = dict.get("label_msg");
getEnrollmentsValues(AbTestValuesListener abTestValuesListener)¶
Asynchronously retrieves a dictionary of values for the variants this device got enrolled.
abTestValuesListener
a callback object used to notify success or error
Example
Retrieves the value of the key label_msg
:
AbTesting abTesting = AbTesting.getInstance();
abTesting.getEnrollmentsValues(new AbTestValuesListener() {
@Override public void onValuesReceived(Map<String, String> values) {
String labelMsg = values.get("label_msg");
}
@Override public void onError(String message) {
// something wrong happened
}
});
getValueOr(String key, String defaultValue)¶
Returns the value of the provided key
or defaultValue
if none was found
getValue(String key)¶
Returns the value of the provided key
or null
if none was found