Flutter (Beta)

Taboola Package for Flutter

🚧

Beta Product!

Please note that the Taboola Flutter Package is in beta, and still might be not stable. Please contact your Taboola contact before moving forward with any Flutter integration

Step 1: Dependencies & Permissions

General

  1. You can incorporate the Taboola Package from the following pub.dev
https://pub.dev/packages/taboola_sdk
  1. In your project’s pubspec.yaml, under ‘dependencies:’, add:
    taboola_sdk:0.0.2+3

  2. Don't forget to turn off the Taboola logs before uploading your app to the Google Play / App Store

Call Taboola.disableTaboolaLogs = true;

Android

Add permissions in your relevant AndroidManifest.xml, above the <application> tag, add

<uses-permission android:name="android.permission.INTERNET"/>

iOS

Add permissions in your relevant Info.plist add the following between the <plist> tags:

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSAllowsArbitraryLoadsInWebContent</key>
        <true/>
    </dict>

Step 2: Init Taboola

  1. Import Taboola to your project
import 'package:taboola_sdk/taboola.dart';
  1. Create a PublisherInfo object with your publisher name
PublisherInfo("sdk-tester-demo")
  1. Execute the init function with the PublisherInfo object
Taboola.init(<Your_PublisherInfo>)

Step 3: Add Taboola to the build stack

Import the relevant components

Import 'package:taboola_sdk/standard/taboola_standard_listener.dart';
Import 'package:taboola_sdk/standard/taboola_standard.dart';

//If you initialized Taboola in a different file, you might need to 
//import the TaboolaStandardBuilder: 
Import 'package:taboola_sdk/standard/taboola_standard_builder.dart';

Obtain a TaboolaStandard Instance:

  1. Get an instance builder
TaboolaStandardBuilder taboolaStandardBuilder = Taboola.getTaboolaStandardBuilder(pageUrl, pageType);
  1. Add the Taboola asset
TaboolaStandard taboolaStandard = taboolaStandardBuilder.build(placement, mode, isFeed, taboolaStandardListener);

See taboolaStandardListener creation in the next step.
Note: The ‘isFeed’ boolean will change which Widget is returned:

  • isFeed = true: Returns a limited, “TaboolaWidget” that can be placed mid-page or page-bottom.
  • isFeed = false: Returns an endless, “TaboolaFeed” Widget that’s meant to be placed in page-bottom.

📘

Using Taboola Feed

If you're adding Taboola Feed, please add it as the bottom most item in your layout. TaboolaFeed must be a child of your scrolling Widget.

📘

Using Custom ScrollScontroller

TaboolaStandard can accept an optional custom ScrollController. Please only use this when necessary. A limited item Taboola Widget does not need a custom ScrollController.

_taboolaStandard = _taboolaStandardBuilder.build(placement, mode, true, _taboolaStandardListener, <YOUR_SCROLL_CONTROLLER>);

Publisher Parameters

Working with Taboola SDK will require a set of arguments that are best achieved consulting a Taboola contact.

  • PublisherInfo (Globally unique, set once per app lifetime)
  • PublisherId - Your publisher identifier in Taboola ecosystem.
  • PageUrl - The full URL of public web page which reflects the current screen's content
  • PageType - Your page type parameter as provided by your Taboola account manager
  • Mode - Your mode parameter as provided by your Taboola account manager
  • Placement - Your placement parameter as provided by your Taboola account manager

Step 4: Set Callbacks

🚧

Pay Attention!

It is important to implement the taboolaDidFailToLoad method for the unlikely event of an error or no fill.

Create a TaboolaStandardListener object to receive callbacks regarding your TaboolaStandard instance:

TaboolaStandardListener  taboolaStandardListener = TaboolaStandardListener(taboolaDidResize,taboolaDidShow,taboolaDidFailToLoad,taboolaDidClickOnItem);

taboolaDidResize

This callback is called every time Taboola’s web content resizes.
Params:

  • Placement: The name of the Taboola Widget.
  • Height: The min. between 1 screen size & current WebView height (wraps around its web content)

taboolaDidShow

  • Placement: The name of the Taboola Widget.
  • General: This is called when Taboola web content starts rendering (on or off screen), treat this more like an onLoadSuccess()

taboolaDidFailToLoad

Called when Taboola failed to display content or timed out.
Params:

  • Placement: The name of the Taboola Widget.
  • Error: The error message related.

taboolaDidClickOnItem

This callback will be called when a user clicks on a Taboola item. (String placement, String itemId, String clickUrl, bool organic)
Params:

  • Placement: The name of the Taboola Widget.
  • ItemId: The id of the item clicked.
  • ClickUrl: The url of the item clicked.
  • Organic: True if the clicked item is organic, false if it’s sponsored.
    Return value:
    This callback also implements logic regarding who handles the user click. If you return true: Taboola will handle the click automatically. If you return false: In case of organic item/article, you will be able to handle the click yourself. Sponsored items will still be handled by Taboola at any case.

TaboolaStandardListener expects Functions as arguments

Step 5: Submit your app for review

You're done!
When you have finished the integration, contact your account manager and send a debuggable = version of your Android and iOS projects. Reach out to your Taboola contact for more information

Sepcial Case - NestedScrolling

If you have your own custom ScrollController, please set it in the optional argument when building TaboolaStandard instance

When adding “Taboola Feed” into a screen bellow a scrollable Widget. Taboola’s best-suggested practice is as followed:

  1. Create a CustomScrollView
  2. Set Taboola’s ScrollController as the CustomScrollView’s controller. This will allow Taboola to transfer scrolling between its Feed and your content.
  3. Add your content into a SliverList.
  4. Add your TaboolaStandard instance as a child of a SliverToBoxAdapter.
    If you have your own custom ScrollController, please set it in the optional argument when building TaboolaStandard instance

Code Samples:

_taboolaStandard = _taboolaStandardBuilder.build(placement, mode, true, _taboolaStandardListener, <YOUR_SCROLL_CONTROLLER>);

📘

What is my pubisher name?

You should contact your Taboola contact to get your production codes, including the publisher name

GDPR & CCPA

Taboola Flutter plugin can get a direct signal for the current user about the GDPR and CCPA status.
Currently, the plugin does not support the IAB CCPA, TCFv1, and TCFv2 frameworks

GDPR

It is possible to forward the consent status to Taboola plugin on when using a dedicated flag - cex. The consent boolean value (in string format) should be passed on each session.
By default, the value of this flag is set to "true" - allowing Taboola to use the user's data. Please use the flag only when the end-user is GDPR subject and set it to "true" (user-provided consent), or "false" (user didn't provide consent).

HashMap<String, dynamic> extraProperties = new HashMap<String, dynamic>(); //map has to be of <String, dynamic> structure.

extraProperties.putIfAbsent("cex", () => "true"); //or “false”

Taboola.init(PublisherInfo(publisher), extraProperties: extraProperties);

CCPA

It is possible to forward the CCPA "Do Not Sell" (dns) status to Taboola plugin on each time the widget/feed is initialized using a dedicated flag - cdns. The value (in string format) should be passed on each session.

  • true - CCPA applies, and the end-user opted-out per CCPA requirements
  • false - CCPA applies, and the end-user didn't opt-out per CCPA requirements
  • none - CCPA does not apply (the default status)
    By default, the value of this flag is set to none - the end-user is not CCPA subject, allowing Taboola to use the user's data. It is recommended to place these lines alongside the other settings, such as publisher name, etc
HashMap<String, dynamic> extraProperties = new HashMap<String, dynamic>(); //map has to be of <String, dynamic> structure.

extraProperties.putIfAbsent("cdns", () => "true"); //or “false”

Taboola.init(PublisherInfo(publisher), extraProperties: extraProperties);

Test it yourself

You can use the following test parameters for your development efforts

Parameter

Endless Feed

Widget

PublisherInfo

"sdk-tester-demo"

"sdk-tester-demo"

Placement

"Feed without video"

"Below Widget"

PageURL

"https://blog.taboola.com"

"https://blog.taboola.com"

PageType

"article"

"article"

TargetType

"mix"

"mix"

Mode

"thumbs-feed-01"

"alternating-widget-without-video-1x4"

Contact us & Terms

If you wish to integrate the Taboola Flutter package into any commercial applications, please make sure you have a green light from your Taboola contact and from Taboola Product team

Using this Flutter package is subject to Taboola terms of use and privacy policy

Updated 4 months ago


Flutter (Beta)


Taboola Package for Flutter

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.