Remote configuration for Android apps
Remote Config enables you to change the behavior or appearance of the app by making changes to the server side values. To add the parameters and conditions in the Remote Config UI, refer to the User Guide.
Add the SDK
- Before your begin, make sure that Apptics is integrated into your project by following the Integration Guide.
- Declaring remote config dependency using Apptics BoM.
Copieddependencies {
// ...
// Apptics BoM, latest version is mentioned in the integration guide.
implementation platform('com.zoho.apptics:apptics-bom:[latest-version]')
// Since BoM version is specified, no need to explicitly specify the dependency version.
implementation 'com.zoho.apptics:apptics-rc'
}
- If you do not use Apptics BoM you can directly declare the remote config dependency with its version.
Copieddependencies {
// Have to explicitly mention the version, if you are not using BoM.
// latest version is mentioned in the integration guide.
implementation 'com.zoho.apptics:apptics-rc:[latest-version]'
}
Note: It is recommend to use Apptics BoM to avoid unnecessary compatibility issues.
- Initialize remote config SDK in Application onCreate() method.
CopiedApptics.init(this)
Single value fetch
Use the below snippet to fetch a single param value. The returned param value can be null if ParamName is invalid or if something else went wrong.
CopiedAppticsRemoteConfig.fetchValue("ParamName", { value ->
if (value != null) {
}
})
For versions 0.1.1 and above: Callback will be invoked with value fetched from the network in the current app session. If fallbackWithOfflineValue param is enabled, callback will be invoked with previously fetched values in case of network error or some other error scenarios.
For versions below 0.1.1: Callback will be invoked with the value available offline followed by the value currently fetched from the server. To always provide the current fetched value from the server, set the offline param as false.
By default values will not be fetched from Network for every fetch calls, fetchValue/fetchValues method will return cached values if the values are recently fetched from Network. coldFetch param can be enabled, incase if you need fetchvalue methods to always fetch and return the current value from the network.
Enable coldFetch param with caution, since only 3 fetch calls are allowed per minute. Any further fetch calls will return null/default values.
CopiedAppticsRemoteConfig.fetchValue("ParamName", { value ->
if (value != null) {
}
}, false)
Use the fetchValue method without callback for fetching value from worker threads. The fetchValue method without callback will always return the current fetched value from the server.
Copiedval value = AppticsRemoteConfig.fetchValue("ParamName")
Multiple value fetch
Use the below snippet to fetch multiple param values. Pass a HashMap of param names and default values to fetch actual values for the param.
Copiedval paramMap = HashMap<String, String?>()
paramMap["paramName"] = "default value"
AppticsRemoteConfig.fetchValues(paramMap, { data ->
})
For versions 0.1.1 and above: Callback will be invoked with value fetched from the network in the current app session. If fallbackWithOfflineValue param is enabled, a callback will be invoked with previously fetched values in case of network error or some other error scenarios.
For versions below 0.1.1: Callback will be invoked with the value available offline followed by the value currently fetched from the server. To always provide the current fetched value from the server, set the offline param as false.
CopiedAppticsRemoteConfig.fetchValues(paramMap, { data ->
}, false)
Use the fetchValues method without callback for fetching value from worker threads.
Copiedval outputMap = AppticsRemoteConfig.fetchValues(paramMap)
Custom condition criteria
Use the below method to set custom condition criteria for the device.
CopiedAppticsRemoteConfig.setCustomConditionValue("ConditionKey", "Criteria")