Specifying Configuration Sources
Alternate Configuration Location
The SDK's start
method expects to find in your project a configuration file named foresee_configuration.json
by default. However, it is possible to specify an alternate location using the following method:
startWithConfiguration(Application application, String filename);
This is especially useful for debugging. Specify a custom config file when running locally like this:
if (BuildConfig.DEBUG) {
ForeSee.startWithConfiguration(this, "foresee_configuration_debug.json");
} else {
ForeSee.start; // default config
}
Remote Configuration
It's also possible to specify a JSON string directly:
// Replace this configuration JSON with your desired configuration
String jsonConfig =
"{\"clientId\":\"your_client_id\","
+ "\"notificationType\":\"IN_SESSION\",\"sessionReplayEnabled\":true,"
+ "\"measures\":[{\"surveyId\":\"app_test_2\",\"launchCount\": 0}]}";
ForeSee.startWithConfigurationJSON(this, jsonConfig);
This JSON string could originate anywhere (including one of your own servers). So, this method can be used to load a remote configuration.
###Updating a Configuration
To update the configuration after the ForeSee® SDK is started, use the following method:
// Replace this configuration JSON with your desired configuration
String jsonConfig =
"{\"clientId\":\"your_client_id\","
+ "\"notificationType\":\"IN_SESSION\",\"sessionReplayEnabled\":true,"
+ "\"measures\":[{\"surveyId\":\"app_test_2\",\"launchCount\": 0}]}";
ForeSee.updateConfig(yourApplicationRef, jsonConfig);
FCP
ForeSee Android SDK v6.0.0 adds support for ForeSee-hosted remote configuration. Use the following method to start the SDK using a config file hosted with FCP:
// Replace YOUR_APP_ID with your application id
ForeSee.startWithAppId(this,"YOUR_APP_ID", configurationListener);
You can also specify a specific version of the config:
ForeSee.startWithAppId(this,"YOUR_APP_ID", "VERSION", configurationListener);
A/B Testing
FCP supports A/B testing multiple configuration versions using:
public static void addABTest(final String name, int percentage);
Any number of tests can be specified, as long as the sum of all configured percentages is equal to 100. For example, if you've uploaded a config called mobilesdkdevstgtest
with tests called a
and b
, then the SDK could be started like this:
ForeSee.addABTest("a", 20);
ForeSee.addABTest("b", 80);
ForeSee.startWithAppId(this,"mobilesdkdevstgtest", "1", configurationListener);
Updated over 2 years ago