Skip to content


News Feed integration

News Feed data model

Getting the data

To access the News Feed data model, subscribe to News Feed update events:

1
2
3
4
5
6
// Subscribe to feed updates
// Note: you should remove the observer where appropriate
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(feedUpdated:)
                                             name:ABKFeedUpdatedNotification
                                           object:nil];
1
2
3
4
5
6
// Called when the feed is refreshed (via `requestFeedRefresh`)
- (void)feedUpdated:(NSNotification *)notification {
  BOOL updateIsSuccessful = [notification.userInfo[ABKFeedUpdatedIsSuccessfulKey] boolValue];
  // check for success
  // get the cards using [[Appboy sharedInstance].feedController getCardsInCategories:ABKCardCategoryAll];
}
1
2
3
4
5
// Subscribe to feed updates
// Note: you should remove the observer where appropriate
NotificationCenter.default.addObserver(self, selector:
  #selector(feedUpdated),
  name:NSNotification.Name.ABKFeedUpdated, object: nil)
1
2
3
4
5
6
7
// Called when the feed is refreshed (via `requestFeedRefresh`)
private func feedUpdated(_ notification: Notification) {
  if let updateSuccessful = notification.userInfo?[ABKFeedUpdatedIsSuccessfulKey] as? Bool {
    // check for success
    // get the cards using Appboy.sharedInstance()?.feedController.getCardsInCategories(.all);      
  }
}

If you want to change the card data after it’s been sent by Braze, we recommend storing (deep copy) the card data locally, updating it, and displaying it yourself. The cards are accessible via ABKFeedController.

News Feed model

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

Base card model properties

Captioned image card properties

Text announcement card (captioned image without image) properties

Classic card properties

Card methods

Log feed display

When displaying the News Feed in your own user interface, you can manually record News Feed impressions via - (void)logFeedDisplayed;. For example:

1
[[Appboy sharedInstance] logFeedDisplayed];
1
Appboy.sharedInstance()?.logFeedDisplayed()

News Feed view controller integration

Integrating the view controller ABKNewsFeedViewController will display the Braze News Feed.

You have a great deal of flexibility in how you choose to display the view controllers. There are different versions of the view controllers to accommodate different navigation structures.

The News Feed can be integrated with two view controller contexts: navigation or modal.

1
2
ABKNewsFeedTableViewController *newsFeed = [[ABKNewsFeedTableViewController alloc] init];
[self.navigationController pushViewController:newsFeed animated:YES];
1
2
let newsFeed = ABKNewsFeedTableViewController()
self.navigationController?.pushViewController(newsFeed, animated: true)

To customize the navigation bar’s title, set the title property of the ABKNewsFeedTableViewController instance’s navigationItem.

This modal is used present the view controller in a modal view, with a navigation bar on top and a Done button on the right side of the bar. To customize the modal’s title, set the title property of the ABKNewsFeedTableViewController instance’s navigationItem.

If a delegate is NOT set, the Done button will dismiss the modal view. If a delegate is set, the Done button will call the delegate, and the delegate itself will be responsible for dismissing the view.

1
2
ABKNewsFeedViewController *newsFeed = [[ABKNewsFeedViewController alloc] init];
[self presentViewController:newsFeed animated:YES completion:nil];
1
2
let newsFeed = ABKNewsFeedViewController()
self.present(newsFeed, animated: true, completion: nil)

For view controller examples, check out our News Feed sample app.

HOW HELPFUL WAS THIS PAGE?
New Stuff!