Newsroom for Android

Step 1: Install the SDK

The latest version is 2.3.5 (released on September 24th, 2019)

Add Taboola library and its dependency to your project

implementation 'com.taboola:android-sdk:2.3.5'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
  
  

Step 2: Verify the AndroidManifest.xml

Include this line in your app’s AndroidManifest.xml to allow Internet access and read the network state

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

Step 3: Set Proguard rules

###---------- Begin: proguard configuration for Taboola SDK API  ----------
-keepnames class com.taboola.android.integration_verifier.testing.tests.proguard_stub.ProguardVerificationStub
-keep class com.taboola.android.monitor.** {*;}
-dontwarn com.google.gson.annotations.**
###---------- End: proguard configuration for Taboola API  ----------

#### All of the rules below are for Taboola API dependencies. You don't have to modify them

###--------------- Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }

-keepattributes EnclosingMethod

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }

# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

###--------------- End: proguard configuration for Gson ----------

Step 4: Init the SDK

A. Create PublisherInfo

PublisherInfo publisherInfo = new PublisherInfo(<MyPublisherId>).setApiKey(<myApiKey>);
  • MyPublisherId - Your publisher ID as provided to you by Taboola account manager
  • MyApiKey - Your API key as provided to you by Taboola account manager

B. Call Taboola init with your publisher info

Taboola.init(publisherInfo);

Step 5: Report a Newsroom event

Use the reportTaboolaEvent to send an event to the Newsroom platform

Map<String, String> data = new HashMap<>();
Taboola.reportTaboolaEvent(EventType.NEWSROOM, data)

Example of data HashMap

Map < String, String > data = new HashMap < > ();
  data.put("user_type", "subscriber");
  data.put("dashboard", "home-app");
  data.put("region_id", "test");
  data.put("region_index", "1");
  data.put("url", "http://test.com/url");
  data.put("title", "test title");
  data.put("thumbnail_url", "http://test.com/thumburl");
  data.put("premium_content", "true");
Taboola.reportTaboolaEvent(EventType.NEWSROOM, data);

What is your data string?

Please contact your Newsroom account manager for the exact event details you need to send

You're done!

You have successfully shared events from your native app into Newsroom platform

Updated 5 months ago


Newsroom for Android


Suggested Edits are limited on API Reference Pages

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