Skip to content
Product Documentation

Using the Arc XP Content iOS Module

Accessing content from your ArcXP Content backend will primarily involve interfacing with ArcXPContentClient class. A shared instance of this class exists as a property at ArcXPContentManager.client. By calling ArcXPContentClient’s methods on that shared instance, you’ll be able to access any content that is available. 

Results are returned in a completion block with varying Result types, meaning you’ll either receive a specific type of value, or you’ll receive an error.

Fetching Content

Here’s an example of how you might fetch content. This example is fetching a story based on a provided ID.

ArcXPContentManager.client.getStoryContent(identifier: <#ID#>) { result in
// Check the result for a success or failure.
switch result {
case .succcess(let result):
// Handle the result
case .failture(let error):
// Handle the error
}
}

Here’s a high-level list of all the fetching methods you can use with ArcXPContentClient.

getStoryContent(identifier:shouldIgnoreCache:handleResult:)
getGalleryContent(identifier:shouldIgnoreCache:handleResult:)
getRawJsonContent(requestType:identifierOrAlias:handleResult:)
getContentById(identifier:shouldIgnoreCache:handleResult:)
getCollection(alias:index:size:shouldIgnoreCache:handleResult:)
getSectionList(siteHierarchy:shouldIgnoreCache:handleResult:)
getSearch(by:index:size:handleResult:)

For more information on each of these methods, and other capabilities, download our Mobile SDK.

Caching

When content is fetched, it is atomically cached. If content is attempted to be fetched again, the cache will be checked first. However, you may choose to ignore the cache, to make sure you’re getting the latest data from the backend. To ignore the cache, pass a true boolean parameter in the fetch method’s ignoreCache parameter.

Preloading

The module has the ability to preload all elements returned as part of a collection when the collection is retrieved. The default value is true. The effect here is the article fetched with each collection call are stored in the cache for offline usage. Does not download images and videos of preloaded articles.

Pagination

The module returns data in pages as to not return too much data at a single time. All calls except the getSectionList have optional parameters to return a starting value and a page size. The user can specify the from parameter which indicates which record to start returning and then a size parameter to tell how many records to return starting with the from value. Data that is returned in pages will return a Map of data instead of a list where the key value is the index of the result. This will allow the client code to know the index of the last value returned in order to specify a starting index for the next query.