Skip to content

News Feed integration

This reference article covers different News Feed card types, the different card-specific properties available, and a custom integration example for your Android or FireOS application.

In Android, the News Feed is implemented as a fragment available in the Braze Android UI project. Refer to Google’s documentation on fragments for information on adding a fragment to an activity.

The BrazeFeedFragment class will automatically refresh and display the contents of the News Feed and log usage analytics. The cards that can appear in a user’s News Feed are set on the Braze dashboard.

Card types

Braze has five unique card types: banner image, captioned image, text announcement, and short news. Each type inherits common properties from a base model and has the following additional properties.

Base card model properties

The base card model provides foundational behavior for all cards.

Banner image cards are clickable full-sized images.

Captioned image card properties

Captioned image cards are clickable full-sized images with accompanying descriptive text.

Text announcement card (captioned image without image) properties

Text announcement cards are clickable cards containing descriptive text.

Short news card properties

Short news cards are clickable cards with images and accompanying descriptive text.

Session analytics

The Android UI fragments do not automatically track session analytics. To ensure that sessions are tracked correctly, call IBraze.openSession() when your app is opened.

Linking

Linking to the News Feed from an in-app message must be enabled by registering the BrazeFeedActivity within your AndroidManifest.xml.

Custom feed integration

If you want to display the feed in a completely custom manner, it is possible to do so by using your own views populated with data from our models. To obtain News Feed models, you will need to subscribe for News Feed updates and use the resulting model data to populate your views. You will also need to log analytics on the model objects as users interact with your views.

Part 1: Subscribing to feed updates

First, declare a private variable in your custom feed class to hold your subscriber:

1
2
// subscriber variable
private IEventSubscriber<FeedUpdatedEvent> mFeedUpdatedSubscriber;

Next, add the following code to subscribe to feed updates from Braze, typically inside of your custom feed activity’s Activity.onCreate():

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Remove the old subscription first
Braze.getInstance(context).removeSingleSubscription(mFeedUpdatedSubscriber, FeedUpdatedEvent.class);
mFeedUpdatedSubscriber = new IEventSubscriber<FeedUpdatedEvent>() {
  @Override
  public void trigger(final FeedUpdatedEvent event) {
    // This list of Card objects included in the FeedUpdatedEvent should be used to populate your News Feed views.
    List<Card> cards = event.getFeedCards();
    // your logic here
  }
};
Braze.getInstance(context).subscribeToFeedUpdates(mFeedUpdatedSubscriber);

// Request a refresh of feed data
Braze.getInstance(context).requestFeedRefresh();

We also recommend unsubscribing when your custom feed activity moves out of view. Add the following code to your activity’s onDestroy() lifecycle method:

1
Braze.getInstance(context).removeSingleSubscription(mFeedUpdatedSubscriber, FeedUpdatedEvent.class);

Part 2: Logging analytics

When using custom views, you will need to log analytics manually since analytics are only handled automatically when using Braze views.

To log a display of the feed, call Braze.logFeedDisplayed().

To log an impression or click on a Card, call Card.logClick() and Card.logImpression() respectively.

HOW HELPFUL WAS THIS PAGE?
New Stuff!