Content cards
Default feed
Show content cards with the built-in SwiftUI and Compose feed, which orders, dismisses and logs cards for you.
Add one view and your app shows the signed-in user's content cards, with impressions, clicks and dismissals logged for you.
Before you start
- The SDK is configured and the user is identified. See Quickstart: iOS or Quickstart: Android.
- iOS: your target links the
HeraldUIlibrary as well asHeraldSDK. - Android: your app depends on
herald-uias well asherald-core.
1. Add the feed
import SwiftUI
import HeraldUI
struct InboxView: View {
var body: some View {
NavigationStack {
ContentCardFeed()
.navigationTitle("For you")
}
}
}import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.foundation.layout.padding
import com.herald.ui.ContentCardFeed
@Composable
fun InboxScreen() {
Scaffold { padding ->
ContentCardFeed(modifier = Modifier.padding(padding))
}
}From UIKit, wrap the feed in a hosting controller: UIHostingController(rootView: ContentCardFeed()). From an Android View layout, host it in a ComposeView.
| iOS | Android |
|---|---|
![]() | ![]() |
2. Let users refresh
The feed updates on its own when a sync brings new cards. Syncs run at session start and when a user is identified. To fetch on demand, for example when the user opens the inbox, call refreshContentCards():
ContentCardFeed()
.onAppear { Herald.shared.refreshContentCards() }LaunchedEffect(Unit) { Herald.refreshContentCards() }
ContentCardFeed()What the feed does
| Behavior | Detail |
|---|---|
| Order | Pinned cards first, then newest first. Cards that sort equal keep Herald's order. |
| Impressions | Logged once per card per session, the first time at least half of the card is on screen. Rebuilding the feed or relaunching the app within the session does not log it again. |
| Clicks | A tap logs the click, then opens the card's url. On iOS the URL goes to Herald.shared.deepLinkHandler first, then to the system. On Android it opens with an ACTION_VIEW intent. Cards without a url are not tappable. |
| Dismissal | Dismissible cards can be swiped away. Screen reader users get a Dismiss action. The card disappears at once, the dismissal is logged, and it does not come back on the next sync. |
| Empty state | "No updates right now", in the theme's secondary text color. |
| Expired cards | Left out. A card that expires while the feed is open goes away at its expiry time, without a sync. |
| Sign-out | After reset() or a user switch, the feed empties until the new user's cards arrive. |
Card views use the theme's colors, fonts, corner radius and spacing, follow the system light or dark setting, scale with Dynamic Type and Android font size, and keep every tappable card at least 44 pt (iOS) or 48 dp (Android) tall.
Verify it works
- Run the app, sign in, and have an agent send a content card to that user through the same connection.
- Pull the card in with a new session or a
refreshContentCards()call. It appears at the top of the feed. - Tap it. Your deep link opens. The click reaches Herald with the next batch and is credited to the agent's decision.
- Swipe it away and relaunch the app. It stays gone.
Troubleshooting
- The feed is always empty. The user is not identified, or identity verification rejects the sync. Check that you call
setUserTokenafteridentify. With verification set to Optional, a sync without a token returns no cards. - A card does nothing when tapped. It has no
url. Give the message variant a deep link, or handle taps yourself withonCardClick(see Customizing the feed). - A deep link opens the browser instead of the app (iOS). Set
Herald.shared.deepLinkHandlerto route your scheme inside the app, or register the scheme in your Info.plist. - A card the agent sent never shows. Herald suppresses card sends to users who have no SDK device on that connection yet. Send again after the user has run the app once.

