The showKBFromController
function allows you to display the HelpCrunch Knowledge Base (KB) screen within your iOS app, enabling users to seamlessly access articles and resources. This function is highly configurable, supporting localization settings, custom options, and callbacks for managing user interactions.
Function Signature
+ (void)showKBFromController:(UIViewController * _Nullable)viewController
viewType:(HCSViewType)viewType
forURL:(NSURL *)url
forceLanguageFromURL:(BOOL)forceLanguage
completion:(HCSCompletionHandler _Nullable)completion;
Parameters
Parameter | Type | Default Value | Description |
---|---|---|---|
viewController | UIViewController? | null | ViewController from where SDK will be opened |
viewType | HCSViewType | Can be omitted | Configure how the chat widget displays its initial view |
url | NSURL | Required | The URL of the article to display on the Knowledge Base screen. |
forceApplyLocaleFromUrl | Boolean | Required | If true, the SDK enforces the locale based on the url. |
completion |
HCSCompletionHandler |
null | An optional callback for handling completion or error of the KB opening |
Usage Examples
Open specific Knowledge Base article in your iOS app without additional configurations:
Swift:
HelpCrunch.showKB(from: self,
for: URL(string: "https://docs.helpcrunch.com/en/ios-sdk/configure-your-ios-app-in-helpcrunch"),
forceLanguageFromURL: false) { error in
}
ObjC:
[HelpCrunch showKBFromController:self
forURL:[NSURL URLWithString:@"https://docs.helpcrunch.com/en/ios-sdk/configure-your-ios-app-in-helpcrunch"]
forceLanguageFromURL:false
completion:^(NSError * _Nullable error) {
}];
Open a KB article where only KB window will be available:
Swift:
HelpCrunch.showKB(from: nil,
viewType: .kbFirst,
for: URL(string: "https://docs.helpcrunch.com/en/ios-sdk/configure-your-ios-app-in-helpcrunch"),
forceLanguageFromURL: true) { error in
}
ObjC:
[HelpCrunch showKBFromController:nil
viewType:HCSViewTypeKbOnly
forURL:[NSURL URLWithString:@"https://docs.helpcrunch.com/en/ios-sdk/configure-your-ios-app-in-helpcrunch"]
forceLanguageFromURL:false
completion:^(NSError * _Nullable error) {
}];