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 prefer to prioritize efficiency and reliability 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 string type of data.
| Parameter | Type |
|---|---|
| variableName | String |
| defaultValue | String |
| dataType | ContentOptimizerDataType |
Method Signature
+(NSString *)getContentStringWithName:(NSString *)name defaultString:(NSString *)defaultString dataType:(ContentOptimizerDataType)dataType;Method Examples
The following code snippets show how to use this method in Objective-C and Swift.
[Insider getContentStringWithName:@"variableName" defaultString:@"defaultValue" dataType:ContentOptimizerDataTypeElement];Insider.getContentString(withName: "variableName", defaultString: "defaultValue", dataType: ContentOptimizerDataType.element)Get boolean data
This method allows you to retrieve boolean type of data.
| Parameter | Type |
|---|---|
| variableName | String |
| defaultValue | Boolean |
| dataType | ContentOptimizerDataType |
Method Signature
+(BOOL)getContentBoolWithName:(NSString *)name defaultBool:(BOOL)defaultBool dataType:(ContentOptimizerDataType)dataType;Method Examples
The following code snippets show how to use this method in Objective-C and Swift.
[Insider getContentBoolWithName:@"variableName" defaultBool:true dataType:ContentOptimizerDataTypeElement];Insider.getContentBool(withName: "variableName", defaultBool: true, dataType: ContentOptimizerDataType.element)Get integer data
This method allows you to retrieve integer type of data.
| Parameter | Type |
|---|---|
| variableName | String |
| defaultValue | Integer |
| dataType | ContentOptimizerDataType |
Method Signature
+(int)getContentIntWithName:(NSString *)name defaultInt:(int)defaultInt dataType:(ContentOptimizerDataType)dataType;Method Examples
The following code snippets show how to use this method in Objective-C and Swift.
[Insider getContentIntWithName:@"variableName" defaultInt:10 dataType:ContentOptimizerDataTypeElement];Insider.getContentInt(withName: "variableName", defaultInt: 10, dataType: ContentOptimizerDataType.element)Retrieving Content Without Stored Data
For use cases that require real-time content updates can use alternative methods 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, gain full control over content freshness, ensuring that the latest data is always reflected in their applications. If real-time data is not available at the time of the request, the specified default value will be returned, maintaining a smooth user experience.
Get string data
This method allows you to retrieve string type of data.
| Parameter | Type |
|---|---|
| variableName | String |
| defaultValue | String |
| dataType | ContentOptimizerDataType |
Method Signature
+(NSString *)getContentStringWithoutCache:(NSString *)name defaultString:(NSString *)defaultString dataType:(ContentOptimizerDataType)dataType;Method Examples
The following code snippets show how to use this method in Objective-C and Swift.
[Insider getContentStringWithoutCache:@"variableName" defaultString:@"defaultValue" dataType:ContentOptimizerDataTypeElement];Insider.getContentStringWithoutCache(withName: "variableName", defaultString: "defaultValue", dataType: ContentOptimizerDataType.element)Get boolean data
This method allows you to retrieve boolean type of data.
| Parameter | Type |
|---|---|
| variableName | String |
| defaultValue | Boolean |
| dataType | ContentOptimizerDataType |
Method Signature
+(BOOL)getContentBoolWithoutCache:(NSString *)name defaultBool:(BOOL)defaultBool dataType:(ContentOptimizerDataType)dataType;Method Examples
The following code snippets show how to use this method in Objective-C and Swift.
[Insider getContentBoolWithoutCache:@"variableName" defaultBool:true dataType:ContentOptimizerDataTypeElement];Insider.getContentBoolWithoutCache(withName: "variableName", defaultBool: true, dataType: ContentOptimizerDataType.element)Get integer data
This method allows you to retrieve integer type of data.
| Parameter | Type |
|---|---|
| variableName | String |
| defaultValue | Integer |
| dataType | ContentOptimizerDataType |
Method Signature
+(int)getContentIntWithoutCache:(NSString *)name defaultInt:(int)defaultInt dataType:(ContentOptimizerDataType)dataType;Method Examples
The following code snippets show how to use this method in Objective-C and Swift.
[Insider getContentIntWithoutCache:@"variableName" defaultInt:10 dataType:ContentOptimizerDataTypeElement];Insider.getContentIntWithoutCache(withName: "variableName", defaultInt: 10, dataType: ContentOptimizerDataType.element)