Suggested readings: App Content Optimizer, Use Cases for App Content Optimizer
The following methods are required to create variables for App Content Optimizer, depending on the data type.
Retrieving Content with Stored Data
The Content Optimizer feature provides methods that store the last retrieved data on the device. When using these methods, the SDK retrieves and returns the most recently fetched value, reducing the need for repeated network requests. This approach enhances performance and ensures consistent content availability across sessions.
If you prefer to prioritize efficiency and reliability, you can use these methods to maintain seamless content delivery without requiring a fresh data request each time.
Get string data
This method allows you to retrieve a string type of data.
| Parameter | Type |
|---|---|
| variableName | String |
| defaultValue | String |
| dataType | ContentOptimizerDataType |
Method Signature
public String getContentStringWithName(String variableName, String defaultValue, ContentOptimizerDataType dataType)Method Example
Insider.Instance.getContentStringWithName("variableName", "defaultValue", ContentOptimizerDataType.ELEMENT);Get boolean data
This method allows you to retrieve a boolean type of data.
| Parameter | Type |
|---|---|
| variableName | String |
| defaultValue | Boolean |
| dataType | ContentOptimizerDataType |
Method Signature
public boolean getContentBoolWithName(String variableName, boolean defaultValue, ContentOptimizerDataType dataType)Method Example
Insider.Instance.getContentBoolWithName("variableName", true, ContentOptimizerDataType.ELEMENT);Get integer data
This method allows you to retrieve an integer type of data.
| Parameter | Type |
|---|---|
| variableName | String |
| defaultValue | Integer |
| dataType | ContentOptimizerDataType |
Method Signature
public int getContentIntWithName(String variableName, int defaultValue, ContentOptimizerDataType dataType)Method Example
Insider.Instance.getContentIntWithName("variableName", 10, ContentOptimizerDataType.ELEMENT);Retrieving Content Without Stored Data
For use cases that require real-time content updates, alternative methods can be used that always request the latest data from the backend instead of using stored values. These methods ensure that the most up-to-date information is retrieved at the time of request, making them ideal for time-sensitive campaigns or dynamic content updates.
By using this approach, you gain full control over content freshness, ensuring that the latest data is always reflected in your applications. If real-time data is unavailable at the time of the request, the specified default value will be returned, ensuring a smooth user experience.
Get string data
This method allows you to retrieve a string type of data.
| Parameter | Type |
|---|---|
| variableName | String |
| defaultValue | String |
| dataType | ContentOptimizerDataType |
Method Signature
public String getContentStringWithoutCache(String variableName, String defaultValue, ContentOptimizerDataType dataType)Method Example
Insider.Instance.getContentStringWithoutCache("variableName", "defaultValue", ContentOptimizerDataType.ELEMENT);Get boolean data
This method allows you to retrieve a boolean type of data.
| Parameter | Type |
|---|---|
| variableName | String |
| defaultValue | Boolean |
| dataType | ContentOptimizerDataType |
Method Signature
public boolean getContentBoolWithoutCache(String variableName, boolean defaultValue, ContentOptimizerDataType dataType)Method Example
Insider.Instance.getContentBoolWithoutCache("variableName", true, ContentOptimizerDataType.ELEMENT);Get integer data
This method allows you to retrieve an integer type of data.
| Parameter | Type |
|---|---|
| variableName | String |
| defaultValue | Integer |
| dataType | ContentOptimizerDataType |
Method Signature
public int getContentIntWithoutCache(String variableName, int defaultValue, ContentOptimizerDataType dataType)Method Example
Insider.Instance.getContentIntWithoutCache("variableName", 10, ContentOptimizerDataType.ELEMENT);