SCSKnowledgeManager
@interface SCSKnowledgeManager : NSObject
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.
-
Authentication settings used for network interactions and offline caching.
This value will change if the
+defaultManagerinstance is used.See
+defaultManagerDeclaration
Objective-C
@property (readonly, strong, nonatomic) SCSAuthenticationSettings *_Nonnull authenticationSettings;Swift
var authenticationSettings: SCSAuthenticationSettings { get } -
Singleton instance of the knowledge manager.
This singleton instance automatically uses the user account currently selected within
SCServiceCloud.account.Declaration
Objective-C
@property (readonly, strong, atomic, class) SCSKnowledgeManager *_Nonnull defaultManager;Swift
class var `default`: KnowledgeManager { get }Return Value
Shared knowledge manager instance.
-
Returns a knowledge manager instance with the given user account.
Declaration
Objective-C
+ (nullable SCSKnowledgeManager *)knowledgeManagerWithAuthenticationSettings: (nonnull SCSAuthenticationSettings *)authenticationSettings;Swift
/*not inherited*/ init?(authenticationSettings: SCSAuthenticationSettings)Parameters
authenticationSettingsAuthentication settings to use.
Return Value
Initialized knowledge manager.
-
Triggers a fetch to load the categories for the user’s organization.
The data returned will automatically be cached, and any changes that have occurred since the previous fetch will be updated.
Declaration
Objective-C
- (void)fetchAllCategoriesWithCompletionHandler: (nullable void (^)(NSArray<SCSCategoryGroup *> *_Nullable __strong, NSError *_Nullable __strong))completionHandler;Swift
func fetchAllCategories(completionHandler: (([SCSCategoryGroup]?, Error?) -> Void)? = nil)Parameters
completionHandlerOptional completion block to be called when the operation completes.
-
Indicates whether this knowledge manager has fetched new category information since it was created.
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.
Declaration
Objective-C
- (BOOL)hasFetchedCategories;Swift
func hasFetchedCategories() -> BoolReturn Value
YESif this instance has successfully completed-fetchAllCategoriesWithCompletionHandler:, otherwiseNO. -
Indicates whether this knowledge manager has determined the supported languages since it was created.
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.
Declaration
Objective-C
- (BOOL)hasFetchedSupportedLanguages;Swift
func hasFetchedSupportedLanguages() -> BoolReturn Value
YESif this instance has successfully completed-fetchKnowledgeSupportedLanguagesWithCompletionHandler:, otherwiseNO -
Returns all the public category groups for the current organization.
Warning
This array may be empty if no data has been previously cached.
See
Declaration
Objective-C
- (nonnull NSArray<SCSCategoryGroup *> *)allCategoryGroups;Swift
func allCategoryGroups() -> [SCSCategoryGroup]Return Value
Array of
SCSCategoryGroupinstances -
Returns the category group matching the given name.
Warning
This may return
nilif no data has been previously cached.See
Declaration
Objective-C
- (nullable SCSCategoryGroup *)categoryGroupWithName:(nonnull NSString *)name;Swift
func categoryGroup(withName name: String) -> SCSCategoryGroup?Parameters
nameName of the category group to return.
Return Value
SCSCategoryGroupinstance, ornilif none is found with that name. -
Returns a cached article object with the given article ID.
See
Declaration
Objective-C
- (nullable SCSArticle *) articleWithId:(nonnull NSString *)articleIdOrName error:(NSError *__autoreleasing _Nullable *_Nullable)error;Swift
func article(withId articleIdOrName: String, error: ()) throws -> SCSArticleParameters
articleIdOrNameArticle ID or URL Name to search for.
errorOptional pointer to an error variable.
Return Value
SCSArticlematching the given ID, ornilif no article is found in the cache with that name. -
Undocumented
Declaration
Objective-C
- (nullable SCSArticle*)articleWithId:(NSString*)articleId SCS_API_DEPRECATED_WITH_REPLACEMENT("articleWithId:error:");Swift
func article(withId articleId: String) -> SCSArticle? -
Returns cached article objects matching the given query.
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:methodNote
This ignores the
pageSizeandpageNumberproperties, instead returning all locally-cached articles matching the remaining query parameters.See
See
Declaration
Objective-C
- (void)articlesMatchingQuery:(nonnull SCSArticleQuery *)query completion:(nonnull void (^)( NSArray<SCSArticle *> *_Nullable __strong, NSError *_Nullable __strong))completion;Swift
func articles(matching query: SCSArticleQuery, completion: @escaping ([SCSArticle]?, Error?) -> Void)Parameters
queryQuery to use for identifying articles.
completionCompletion block to invoke when the articles are found.
-
Declaration
Objective-C
- (void)fetchArticlesWithQuery:(nonnull SCSArticleQuery *)query completion:(nullable void (^)( NSArray<SCSArticle *> *_Nonnull __strong, NSError *_Nullable __strong))completion;Swift
func fetchArticles(with query: SCSArticleQuery, completion: (([SCSArticle], Error?) -> Void)? = nil)Parameters
queryQuery to use for identifying articles.
completionCompletion block to invoke when articles are found.
-
Clear the cache data from the disk if the cache exists on the disk.
Declaration
Objective-C
- (void)deleteCacheIfExists: (nonnull void (^)(NSError *_Nullable __strong))completion;Swift
func deleteCacheIfExists(_ completion: @escaping (Error?) -> Void)Parameters
completionCompletion block to invoke when deletion of the cache is completed or if an error occurs.
-
Fetches the supported languages for knowledge.
Declaration
Objective-C
- (void)fetchSupportedLanguagesWithCompletion: (nullable void (^)(NSArray<NSString *> *_Nullable __strong, NSError *_Nullable __strong))completion;Swift
func fetchSupportedLanguages(completion: (([String]?, Error?) -> Void)? = nil)Parameters
completionCompletion block to invoke when the supported languages have been recieved from the org or an error occurs.
Install in Dash
SCSKnowledgeManager Class Reference