public interface

KnowledgeJsProvider

com.salesforce.android.knowledge.ui.KnowledgeJsProvider

Class Overview

Interface for providing JavaScript to Knowledge articles as they are displayed to the user in a WebView.

This interface allows you to provide Javascript that will be applied to every article, and also to provide JavaScript for each individual article. Internally, the JavaScript you provide will be embedded into the head of the article's HTML. Please note that this API expects JavaScript as a String and not a file path or URL. If you have JavaScript from multiple sources then you must merge them into a single String.

You must pass your instance of KnowledgeJsProvider to your KnowledgeUIConfiguration object via setJsProvider(KnowledgeJsProvider) before launching Knowledge UI for it to be used.

This interface does not specify how JavaScript is sourced. We recommend loading JavaScript from disk and reading the contents into a String value as early as possible, as this is a UI blocking operation.

Summary

Public Methods
abstract String getJsForArticle(ArticleSummary articleSummary)
Provide JavaScript content to be embedded in the head of a Knowledge article as it is being loaded into a WebView.

Public Methods

public abstract String getJsForArticle (ArticleSummary articleSummary)

Provide JavaScript content to be embedded in the head of a Knowledge article as it is being loaded into a WebView. The ArticleSummary of the article is given as an argument so it can be identified and you may return JavaScript tailored for that article.

This method will be called each time an article is loaded.

Parameters
articleSummary The ArticleSummary of the article being loaded
Returns
  • JavaScript to be applied to a specific article