SDK DocumentationRecipesAnnouncementsSupport Forum
AndroidiOSAnnouncementsSupport Forum

SDK Reference

Feed and Widget via Native

SDK ReferenceRequiredDescription
public TaboolaWidget setPublisher(String publisher)MandatorySets your account name (publisher) in the Widget
public TaboolaWidget setPlacement(String placement)MandatoryAs a part of Taboola's integration different blocks of the UI are defined in your app to be displayed in various placements. Each of these blocks have a meaningful name. Taboola's configuration relies on the placement name to serve content in the UI correctly.
public TaboolaWidget setMode(String mode)MandatoryMode is an arrangement of content items that users will see in the Widget. This is the UI Layout of your Widget.
public TaboolaWidget setPageType(String pageType)MandatoryThe page type is a categorization of the content in the source and target pages in your app. Taboola representatives will give you the best values to improve the recommendations returned.
public TaboolaWidget setPageUrl(String pageUrl)MandatoryIf you have a web site with a page that has a parallel content to the native Android page you're showing the widget in, add that page's url. If you don't have such a page, put the classpath to the relevant Activity (for example: your.package.name.MyActivity1). Note: In any case, work closely with Taboola to enter the optimal values here.
public TaboolaWidget setTargetType(String targetType)OptionalDefault: "mix". (This can also be set via XML as target_type). Change only if instructed to do so by your Taboola account manager.
public boolean isItemClickEnabled() - @DeprecatedOptionalDefault: true. (This can also be set via XML as item_click_enabled)
public TaboolaWidget setItemClickEnabled(boolean enabled) - @DeprecatedOptionalEnables/disables click propogation inside TaboolaWidget.
public TaboolaWidget setAutoResizeHeight(boolean shouldAutoResize)OptionalDefault: true. Determines whether TaboolaWidget can resize when the loaded content requires it to do so (this can also be set via XML as auto_resize_height)
public TaboolaWidget setTaboolaEventListener(TaboolaEventListener taboolaEventListener)OptionalAttaches a TaboolaEventListener to the TaboolaWidget to enable intercepting clicks and handle height resize events
public TaboolaWidget setOptionalPageCommands(HashMap<String, String> optionalPageCommands)OptionalEnables pushing commands to the TaboolaWidget, as used in the Taboola JavaScript API. This sets the TaboolaWidget attributes. You can use keys from class com.taboola.android.utils.Const (This is the same as setting every attribute individually via setMode(String mode), setPublisher(String publisher), etc.)
public void fetchContent()MandatoryAfter initializing TaboolaWidget, call this method to fetch the recommendations
public void refresh()OptionalRefreshes the recommendations displayed on the TaboolaWidget.
public void setLogLevel(Logger.Level logLevel)OptionalSet the level of log output of the widget. (the default level is ERROR)
public void reset()OptionalResets the TaboolaWidget- All content and pushed commands are cleared. New commands must be pushed before fetching data again.
public void setInterceptScroll(boolean interceptScroll)OptionalSet whether the widget should handle the scroll automatically (see the feed section).
public void registerScrollToTopListener(ScrollToTopListener scrollToTopListener)OptionalA callback that notifies when the widget is on the top of the screen and is scrolled up (used for feed handling).
public void unregisterScrollToTopListener();OptionalA callback that notifies when the widget is on the top of the screen and is scrolled up (used for feed handling).
public TaboolaWidget setOptionalWidgetStyle(String newCSSStyle)OptionalForces CSS rules over the TaboolaWidget online HTML template
public TaboolaWidget setUserId(String userId)OptionalAn opaque, anonymized and unique identifier of the user in the publisher’s eco-system. This identifier should be identical across applications and devices (e.g. hashed e-mail, or login).
public TaboolaWidget.setExtraProperties(<hashmap of key and values>)OptionalAdding an option to pass a feature flag to the SDK.
<hashmap>('user_type','value')OptionalAn agreed enum that represents the publisher user type category (“subscriber”, “registered”, “guest”, “other”)
<hashmap>("hideScrollingBars","false")OptionalHides the scrolling bars of the taboolaWidget object. The default value is false - showing the scrolling bars
<hashmap>("allowFileAccess","false")OptionalPreventing the Android webview from accessing local files. The default value is false
<hashmap>("hideScrollingBars","false")OptionalHiding the Android webview scrolling bars from showing when using Feed. The default value is false
<hashmap>("darkMode","true")OptionalEnabling/disabling dark mode. Please contact your account/solution manager before using this code
public TaboolaWidget setViewId(String userId)OptionalAdding a unique string of digits to the TaboolaWidget. Giving the same value to other TaboolaWidget object will help avoid duplications when there are more than one Taboola asset on the screen

Feed and Widget via JS

public class TaboolaJs

SDK ReferenceRequiredDescription
public static TaboolaJs getInstance()This returns a singleton instance of the SDK.
public TaboolaJs init(Context applicationContext)MandatoryThis initializes TaboolaJs and requires calling before any other method of the JS SDK. This is usually performed in the Application class in OnCreate().
public TaboolaJs registerWebView(WebView webView)This registers WebView within Taboola JS SDK and requires to be registered before the page is (re)loaded. It injects android.webkit.JavascriptInterface with the name declared as TaboolaJs.INJECTED_OBJECT_NAME into the given WebView.
Note: When WebView is no longer needed it must be unregistered to avoid leaks.
See also: TaboolaJs.unregisterWebView(WebView)
public TaboolaJs registerWebView(WebView webView, OnRenderListener onRenderListener)This registers WebView within Taboola JS SDK and requires to be registered before the page is (re)loaded. it injects android.webkit.JavascriptInterface with the name declared as TaboolaJs.INJECTED_OBJECT_NAME into the given WebView.
Note: When WebView is no longer needed it must be unregistered to avoid leaks.
See also: TaboolaJs.unregisterWebView(WebView)
public TaboolaJs unregisterWebView(WebView webView)This unregisters WebView within the Taboola JS SDK. If the Android version is HONEYCOMB (Api 11) or higher then the previously injected android.webkit.JavascriptInterface is removed.
See also: TaboolaJs.registerWebView(WebView)
public TaboolaJs setLogLevel(int logLevel)This sets the log level for the SDK. logLevel constants are found in the com.taboola.android.utils.Logger class, for example Logger.DEBUG.
public TaboolaJs setOnRenderListener(WebView webView, @Nullable OnRenderListener onRenderListener)This registers a listener to be called when recommendations have succeeded or failed to render (called separately for each placement).
public TaboolaJs setOnClickListener(TaboolaOnClickListener onClickListener)The SDK enables the user to intercept recommendation clicks, and block the default click handling for organic items.

Returning false in TaboolaOnClickListener.onItemClick(String, String, String, boolean) blocks the default behavior, and enables the user to display the recommendation content on their own.
Note: The return value is ignored for non-organic items.
The listener is called every time a user clicks a recommendation, immediately before triggering the default behavior.

public interface OnRenderListener

SDK ReferenceRequiredDescription
void onRenderSuccessful(WebView webView, String placementName)The listener to be called when recommendations have succeeded or failed (called separately for each placement).
void onRenderFailed(WebView webView, String placementName, String errorMessage)The listener to be called when recommendations have succeeded or failed (called separately for each placement).