Advanced Options
Android Web - Advanced Options
You are viewing the V4 docs. This is the preferred version for Android and iOS.
To select an earlier version, use the nav bar (above):
Sample App
While reading the documentation, take a look at our Sample App.
Working with ViewPager
When working with ViewPager
, make sure to fetch Taboola content when the next page is visible to the user (not before).
- For each JS tag in the of your web content, add
lazyFetch: true
:
<script type="text/javascript">
...
_taboola["mobile"].push( {
lazyFetch: true // If you are using `ViewPager`
});
</script>
- Because you added a
lazyFetch
directive within the JS tag, you must fetch Taboola content via your Java code:
@Override
public void onPageSelected() {
mWebUnit.fetchContent(); // When using `ViewPager`
}
ViewPager
If you prefetch more than 1 page using ViewPager:
- Fetch Taboola content when the next page is visible to the user - i.e. in the
onPageSelected
method.- If the
onPageSelected
method is fired more than once, make sure to fetch content once only.
Dark Mode
Dark mode is not supported by default. For dark-mode placements, contact your Taboola Account Manager.
Once Taboola has configured your dark-mode placements, you can use the following code in your application:
// Define a map with extra properties:
HashMap<String, String> extraProperties = new HashMap<String, String>() {{ put("darkMode", "true"); }};
// Set the extra properties within the Unit instance:
tblWebUnit.setUnitExtraProperties(extraProperties);
Opening Audience Exchange (AE) Items in App
If your widget or feed feature AE items and you wish to open these items within the app instead of an external web view, please see the following steps below.
1: Add the extra property allowAudienceExchangeClickOverride
to Taboola's global properties:
HashMap<String, String> extraProperties = new HashMap<String, String>() {{ put("allowAudienceExchangeClickOverride", "true"); }};
Taboola.setGlobalExtraProperties(extraProperties);
2: Override the onItemClick
Listener to implement your desired behavior:
TBLWebUnit tblWebUnit =
tblWebPage.build(<Context>, <placementName>, <mode>, <placementType>, new TBLWebListener(){
@Override
onItemClick(String placementName, String itemId, String clickUrl, boolean isOrganic, @Nullable String customData) {
try {
data = new JSONObject(customData);
if (data.has("isAudienceExchange") && data.optBoolean("isAudienceExchange", false) {
// Handle Audience Exchange items
return false;
}
} catch (Exception exception) {
exception.printStackTrace();
}
return true;
});
Updated 11 days ago