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 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
Verint XM Android SDK v6.0.0 adds support for Verint-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", sdkListener);
You can also specify a specific version of the config:
ForeSee.startWithAppId(this,"YOUR_APP_ID", "VERSION", sdkListener);
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", sdkListener);
Error Handling for invalid configuration json
As mentioned above if you provide an alternative location using for example the method below, the SDK will first attempt to load the configuration from the file specified:
startWithConfiguration(Application application, String filename);
If any issues occur when loading this configuration, for example missing file or file contains malformed json, then the SDK will then attempt to load the configuration from the local default file foresee_configuration.json
.
If it fails to load this local configuration file then the SDK will handle that error in the following 2 ways depending on which SDK listener is implemented:
Error Handling using old listener ForeSeeSDKConfigurationListener
(deprecated)
The SDK will load an internal configuration which does not contain any measures but will at least allow the SDK to initialise successfully and the callback ForeSeeSDKConfigurationListener.onSDKStarted()
will be invoked. This method is deprecated, so the following method should be used.
Error Handling using new listener VerintSDKListener
To use the VerintSDKListener
, you'll need to call the following method before calling any of the SDK start methods above:
ForeSee.setSDKListener(verintSDKListener);
The SDK will load the same internal configuration as above which always allows the SDK to initialise successfully, however the new callback VerintSDKListener.onSDKStarted(ForeSeeError error, String message)
will be invoked which contains an error and message to indicate that the SDK started with errors.
Updated 6 months ago