Note: if you haven't been specifically instructed by your Tabooola account manager to use this section of TaboolaApi, you should probably use TaboolaWidget which is faster and more simple to integrate.
Initializes TaboolaApi. Must be called before any other method of the SDK. Typically you would want to do it in you Application class in OnCreate()
applicationContext— Application ContextpublisherId— The publisher id in the Taboola systemapiKey— The API key that was provided by Taboola for the application
- a singleton instance of the SDK
public void fetchRecommendations(final TBRecommendationsRequest request, final TBRecommendationRequestCallback callback)
Requests recommendation items.
request—TBRecommendationsRequestwith at least oneTBPlacementRequestcallback— callback to pass result into
public void getNextBatchForPlacement(TBPlacement placement, final TBRecommendationRequestCallback callback)
Used for implementing pagination or infinite scroll (load more items as the user scrolls down). The method gets the next batch of recommendation items for a specified placement. The number of recommendation items in the batch will be the same as in the last request. The name of the returned Placement will have a "counter" added as a suffix. For example, if the original placement name was "article" the new name will be "article 1", next one "article 2", and so on. The counter is incremented on each successful fetch.
placement— placement to request next recommendation items forcallback— this callback will get the results
public void getNextBatchForPlacement(TBPlacement placement, int count, final TBRecommendationRequestCallback callback)
Used for implementing pagination or inifinite scroll (load more items as the user scrolls down). The method gets the next batch of recommendation items for a specified placement. The name of the returned Placement will have a "counter" added as a suffix. For example, if the original placement name was "article" the new name will be "article 1", next one "article 2", and so on. The counter is incremented on each successful fetch.
placement— placement to request next recommendation items forcount— amount of recommendation items to fetchcallback— callback to pass result into
Shows a standard popup with attribution, ad-choices and opt-out data.
This method Must be called when the user clicks on the attribution view ("By Taboola" text or the ad-choices icon).
activityContext— is used to display popup
TaboolaApi allows to intercept recommendation clicks and block default click handling for organic items. If you want to block the default behavior in order to open the link to your organic content natively within your app, return false in TaboolaOnClickListener#onItemClick(String, String, String, boolean)
The return value will be ignored for non-organic items.
The listener will be called every time a user clicks a recommendation, right before triggering the default behavior
To avoid accidental user clicks, the TB views will ignore clicks that were done immediately after the view became visible.
DONT CHANGE THIS VALUE without consulting your Taboola account manager.
onClickIgnoreTimeMs— time in milliseconds
Sets log level for the SDK. You can find logLevel constants in the Logger class, for example Logger.DEBUG.
placeholderDrawable— A placeholder drawable to be used while the image is being loaded.
Initializes a Recommendation request with the required parameters. Placments must be added to the request after initialization in order to fetch recommendations.
pageUrl— a fully qualified (http:// or https://) publicly accessible URL that contains the content and/or meta data for the current source item (the piece of content the recommendations are going to be placed next to).sourceType— the type of the content the recommendations will be placed next to.
Adds a TBPlacementRequest to the TBRecommendationsRequest. Up to 12 TBPlacementRequest per TBRecommendationsRequest are allowed. All placements must have unique names.
*placementRequest — placement to be added
Sets the type of the content the recommendations will be placed next to.
The following values are supported:
sourceType
url— A fully qualified (http:// or https://) publicly accessible URL that contains the content and/or meta data for the current source item (the piece of content the recommendations are going to be placed next to).
userReferrer— The referrer (HTTP header) from the request that led to the current page.
- Parameters:
userUnifiedId— An opaque, anonymized and unique identifier of the user in the publisher’s eco-system. This identifier should be identical cross application and device (e.g. hashed e-mail, or login)
Creates request for a specific placement with the required parameters
name— A text string, uniquely identifying the placementrecCount— A non-negative integer specifying how many recommendations are requested. The API will not return more recommendations than this, though if there are not enough good quality recommendations to satisfy the request, fewer items might be returned.
name— A text string, uniquely identifying the placement
recCount— A non-negative integer specifying how many recommendations are requested. The API will not return more recommendations than this, though if there are not enough good quality recommendations to satisfy the request, fewer items might be returned.
Note that this parameter does not influence the type of sponsored content returned – the mix of the sponsored content types is currently determined by a server side configuration.
Valid values:
targetType— Type of recommended organic content to return.
Sets the size (in pixels) of the thumbnails returned for recommendations. Both parameters (height and width) should either appear together or not appear at all.
In case the thumbnail size parameters are specified, the thumbnail would always preserve its original aspect ratio – it will be scaled to the required size, centered and cropped if needed.
In addition, in case the thumbnail contains a face, we will detect that face by default and ensure it is contained within the generated thumbnail.
widthheight
- list of
TBRecommendationItemsfor this placement
Asynchronously loads the thumbnail images for all RecommendationItems in this Placement to the cache, using the default caching mechanism from Picasso, which is:
- LRU memory cache of 15% the available application RAM
- Disk cache of 2% storage space up to 50MB but no less than 5MB. (Note: this is only available on API 14+ or if you are using a standalone library that provides a disk cache on all API levels like OkHttp)
- Three download threads for disk and network access.
Use this method to make sure the thumbnail images are loaded fast and to create a better user experience. Avoid using it in order reduce device resource consumption, if the app is running on a low-end device.
- a map with the placements where the key is the placement name and the value is a
TBPlacementobject
Returns TBImageView that contains the thumbnail image of the recommendation item. If the TBPlacementRequest contained a thumbnail size, it will be set to that size before the image is loaded.
context— Activity context
TBImageView
Returns a TBTextView which contains the title of the recommended item.
context— Activity context
TBTextView
If branding text is available for the current recommendation item, returns a TBTextView which contains the branding text for the item.
If branding text is not available returns null
context— Activity context
TBTextViewornull
Asynchronously loads the thumbnail image for this RecommendationItem to the cache, using the default caching mechanism from Picasso, which is:
- LRU memory cache of 15% the available application RAM
- Disk cache of 2% storage space up to 50MB but no less than 5MB. (Note: this is only available on API 14+ or if you are using a standalone library that provides a disk cache on all API levels like OkHttp)
- Three download threads for disk and network access.
Use this method to make sure the thumbnail images are loaded fast and to create a better user experience. Avoid using it in order reduce device resource consumption, if the app is running on a low-end device.
No need to call the method again if it was already called on the placement level.
Triggers OnClick event on the RecommendationItem. Should be used when implementing a different gesture for opening recommendation items by the user (e.g. swipe)
Ignores visibility requirements for the click.
Triggers OnClick event on the RecommendationItem. Should be used when implementing a different gesture for opening recommendation items by the user (e.g. swipe)
Ignores visibility requirements for the click.
Triggers OnClick event on the RecommendationItem. Should be used when implementing a different gesture for opening recommendation items by the user (e.g. swipe)
Ignores visibility requirements for the click.
TaboolaApi allows to intercept recommendation clicks and block default click handling for organic items. If you want to block the default behavior in order to open the link to your organic content natively within your app, return false.
The return value will be ignored for non-organic items.
The listener will be called every time a user clicks a recommendation, right before triggering the default behavior