Skip to content

Unread badge

By the end of this page the control that opens Feddy shows the number of unread replies and clears when the user reads them.

The SDK keeps the count current on its own: iOS polls every 30 seconds, the web widget every 45 seconds and whenever the tab becomes visible.

Form {
Button("Support") { Feddy.present() }
.feddyUnreadBadge()
}

This is the badge iOS itself puts on rows in Settings. Nothing is drawn at zero.

A list badge is pinned to the trailing edge and would land outside your chevron. Place the marker yourself:

HStack {
Text("Support")
Spacer()
FeddyUnreadDot(showsCount: true)
Image(systemName: "chevron.forward")
}

Pass showsCount: false for a plain dot.

Observe the published count:

struct RootTabs: View {
@ObservedObject private var unread = FeddyUnread.shared
var body: some View {
TabView {
SupportView()
.tabItem { Label("Support", systemImage: "bubble.left") }
.badge(unread.count)
}
}
}

UIKit apps assign Feddy.onUnreadCountChanged and set tabBarItem.badgeValue from it.

Polling pauses while the app is suspended. Call Feddy.refresh() when the app becomes active so the badge is right before the next poll:

.onChange(of: scenePhase) { phase in
if phase == .active { Feddy.refresh() }
}

With the default launcher there is nothing to do; it shows the count itself.

With launcher: false, feed your own element:

Feddy.init({ projectId: 'fd_XXXXXXXXXXXXXXXX', launcher: false })
const badge = document.querySelector('#help-badge')
Feddy.onUnreadCountChanged = (count) => {
badge.hidden = count === 0
badge.textContent = String(count)
}

A reply is unread until the user opens the conversation it belongs to. Closed conversations never count. Opening the list alone does not clear anything.