AppboyKit (also known as the Objective-C SDK) is no longer supported and has been replaced by the Swift SDK. It will no longer receive new features, bug fixes, security updates, or technical support—however, messaging and analytics will continue to function as normal. To learn more, see Introducing the New Braze Swift SDK.
News Feed integration
News Feed is being deprecated. Braze recommends that customers who use our News Feed tool move over to our Content Cards messaging channel—it’s more flexible, customizable, and reliable. Check out the migration guide for more.
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
Property | Description |
---|---|
idString |
(Read only) The card’s ID set by Braze. |
viewed |
This property reflects if the card is read or unread by the user. |
created |
(Read only) The property is the unix timestamp of the card’s creation time from Braze dashboard. |
updated |
(Read only) The property is the unix timestamp of the card’s latest update time from Braze dashboard. |
categories |
The list of categories assigned to the card, cards without a category will be assigned ABKCardCategoryNoCategory .Available categories: - ABKCardCategoryNoCategory - ABKCardCategoryNews - ABKCardCategoryAdvertising - ABKCardCategoryAnnouncements - ABKCardCategorySocial - ABKCardCategoryAll |
extras |
An optional NSDictionary of NSString values. |
Banner image card properties
Property | Description |
---|---|
image |
(Required) This property is the URL of the card’s image. |
URL |
(Optional) The URL that will be opened after the card is clicked on. It can be an HTTP(S) URL or a protocol URL. |
domain |
(Optional) The link text for the property URL, like @”blog.braze.com”. It can be displayed on the card’s UI to indicate the action and direction of clicking on the card but is hidden in the default Braze News Feed. |
Captioned image card properties
Property | Description |
---|---|
image |
(Required) This property is the URL of the card’s image. |
title |
(Required) The title text for the card. |
description (Required) The body text for the card. |
|
URL |
(Optional) The URL that will be opened after the card is clicked on. It can be an HTTP(S) URL or a protocol URL. |
domain |
(Optional) The link text for the property URL, like @”blog.braze.com”. It can be displayed on the card’s UI to indicate the action and direction of clicking on the card. |
Text announcement card (captioned image without image) properties
Property | Description |
---|---|
title |
(Required) The title text for the card. |
description |
(Required) The body text for the card. |
url |
(Optional) The URL that will be opened after the card is clicked on. It can be an HTTP(S) URL or a protocol URL. |
domain |
(Optional) The link text for the property URL, like @”blog.braze.com”. It can be displayed on the card’s UI to indicate the action and direction of clicking on the card. |
Classic card properties
Property | Description |
---|---|
image |
(Required) This property is the URL of the card’s image. |
title |
(Optional) The title text for the card. |
description |
(Required) The body text for the card. |
URL |
(Optional) The URL that will be opened after the card is clicked on. It can be an HTTP(S) URL or a protocol URL. |
domain |
(Optional) The link text for the property URL, like @”blog.braze.com”. It can be displayed on the card’s UI to indicate the action and direction of clicking on the card. |
Card methods
Method | Description |
---|---|
logCardImpression |
Manually log an impression to Braze for a particular card. |
logCardClicked |
Manually log a click to Braze for a particular card. The SDK will only log a card click when the card has the url property with a valid value. All subclasses of ABKCard have the url property. |
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 that is called by the default behavior of an in-app message click will not respect any delegates you set for the News Feed. If you want to respect that, you must set the delegate on ABKInAppMessageUIController
and implement the ABKInAppMessageUIDelegate
delegate method onInAppMessageClicked:
.
The News Feed can be integrated with two view controller contexts: navigation or modal.
Navigation context - ABKFeedViewControllerNavigationContext
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
.
Modal context - ABKFeedViewControllerModalContext
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.