SCSKnowledgeManager Class Reference

Inherits from NSObject
Declared in SCSKnowledgeManager.h

Overview

A SCSKnowledgeManager object is used to interact with knowledge data such as category groups, categories, and articles.

The knowledge manager abstracts the storage, network retrieval, and queries for interacting with data in an efficient fashion. You can use this object to fetch categories and articles from your org. Once fetched, you can use this object to get cached content. See the SCSArticleQuery class for an explanation on how to query for content.

The knowledge manager caches data for offline use, allowing categories and articles to be used even when no network is available. To stay informed about important changes in the underlying data model, any changes to the underlying categories will be advertised through the use of the following notifications:

  • SCSKnowledgeManagerCategoryAddedNotification – A new category is added.
  • SCSKnowledgeManagerCategoryUpdatedNotification – A category has been modified (e.g. title, child categories, etc)
  • SCSKnowledgeManagerCategoryDeletedNotification – A category has been deleted.

The object of the notification will be the SCSKnowledgeManager instance itself, while the category in question is stored in the notification’s userInfo dictionary under the SCSKnowledgeManagerCategoryKey key.

  userAccount

User account used for network interactions and offline caching.

@property (nonatomic, strong, readonly) SFUserAccount *userAccount

Discussion

This value will change if the defaultManager instance is used.

Declared In

SCSKnowledgeManager.h

+ defaultManager

Singleton instance of the knowledge manager.

+ (instancetype)defaultManager

Return Value

Shared knowledge manager instance.

Discussion

This singleton instance automatically uses the user account currently selected within SCServiceCloud.account.

Declared In

SCSKnowledgeManager.h

+ knowledgeManagerWithUserAccount:

Returns a knowledge manager instance with the given user account.

+ (SCSKnowledgeManager *)knowledgeManagerWithUserAccount:(SFUserAccount *)account

Parameters

account

User account to use.

Return Value

Initialized knowledge manager.

Declared In

SCSKnowledgeManager.h

– fetchAllCategoriesWithCompletionHandler:

Triggers a fetch to load the categories for the user’s organization.

- (void)fetchAllCategoriesWithCompletionHandler:(nullable void ( ^ ) ( NSArray<SCSCategoryGroup*> *__nullable categoryGroups , NSError *__nullable error ))completionHandler

Parameters

completionHandler

Optional completion block to be called when the operation completes.

Discussion

The data returned will automatically be cached, and any changes that have occurred since the previous fetch will be updated.

Declared In

SCSKnowledgeManager.h

– hasFetchedCategories

Indicates whether this knowledge manager has fetched new category information since it was created.

- (BOOL)hasFetchedCategories

Return Value

YES if this instance has successfully completed fetchAllCategoriesWithCompletionHandler:, otherwise NO.

Discussion

Note: It is not always necessary to fetch new categories, especially since that may be a costly operation to perform if your organization has a large number of categories.

Declared In

SCSKnowledgeManager.h

– hasFetchedSupportedLanguages

Indicates whether this knowledge manager has determined the supported languages since it was created.

- (BOOL)hasFetchedSupportedLanguages

Return Value

YES if this instance has successfully completed -fetchKnowledgeSupportedLanguagesWithCompletionHandler:, otherwise NO

Discussion

Note: It is not always necessary to fetch the list, it may be a costly operation it does not need to be done more than once.

Declared In

SCSKnowledgeManager.h

– allCategoryGroups

Returns all the public category groups for the current organization.

- (NSArray<SCSCategoryGroup*> *)allCategoryGroups

Return Value

Array of SCSCategoryGroup instances

Discussion

Warning: This array may be empty if no data has been previously cached.

Declared In

SCSKnowledgeManager.h

– categoryGroupWithName:

Returns the category group matching the given name.

- (nullable SCSCategoryGroup *)categoryGroupWithName:(NSString *)name

Parameters

name

Name of the category group to return.

Return Value

SCSCategoryGroup instance, or nil if none is found with that name.

Discussion

Warning: This may return nil if no data has been previously cached.

Declared In

SCSKnowledgeManager.h

– articleWithId:

Returns a cached article object with the given article ID.

- (nullable SCSArticle *)articleWithId:(NSString *)articleId

Parameters

articleId

Article ID to search for.

Return Value

SCSArticle matching the given ID, or nil if no article is found in the cache with that name.

Declared In

SCSKnowledgeManager.h

– articlesMatchingQuery:completion:

Returns cached article objects matching the given query.

- (void)articlesMatchingQuery:(SCSArticleQuery *)query completion:(void ( ^ ) ( NSArray<SCSArticle*> *_Nullable articles , NSError *_Nullable error ))completion

Parameters

query

Query to use for identifying articles.

completion

Completion block to invoke when the articles are found.

Discussion

This method searches through the database of existing article information stored locally to identify articles. No network operations are invoked through this method, and this can safely be used even when offline. For performing requests against the network, please see the fetchArticlesWithQuery:completion: method

Declared In

SCSKnowledgeManager.h

– fetchArticlesWithQuery:completion:

Fetches articles from the server that match the given query.

- (void)fetchArticlesWithQuery:(SCSArticleQuery *)query completion:(nullable void ( ^ ) ( NSArray<SCSArticle*> *articles , NSError *__nullable error ))completion

Parameters

query

Query to use for identifying articles.

completion

Completion block to invoke when articles are found.

Declared In

SCSKnowledgeManager.h

– deleteCacheIfExists:

Clear the cache data from the disk if the cache exists on the disk.

- (void)deleteCacheIfExists:(void ( ^ ) ( NSError *_Nullable error ))completion

Parameters

completion

Completion block to invoke when deletion of the cache is completed or if an error occurs.

Declared In

SCSKnowledgeManager.h

– fetchSupportedLanguagesWithCompletion:

Fetches the supported languages for knowledge.

- (void)fetchSupportedLanguagesWithCompletion:(nullable void ( ^ ) ( NSArray<NSString*> *__nullable languages , NSError *__nullable error ))completion

Parameters

completion

Completion block to invoke when the supported languages have been recieved from the org or an error occurs.

Declared In

SCSKnowledgeManager.h