iOS Setup

Hub

Requires SDK 4.13.0 or later

The Hub (previously known as the Communication Hub) is an embeddable app area that includes an inbox of posts and other features. It is intended to be embedded within a tab bar item in the app, and includes support for badging the tab bar item when new content is available.

Hub

This feature is distinct from the legacy "Inbox" feature. The legacy Inbox (InboxViewController et al) is deprecated and will be removed in a future release.


Prerequisites

Ensure that you have adopted silent push support, as described in the Background Content-Available Push section of the Push Notifications guide. This is needed for properly badging the app in the background when a new Inbox post becomes available.

App Icon Badging

On iOS, the Rover SDK automatically badges the app icon with the post unread count when posts arrive via silent push notifications. This happens in the background without requiring the app to be actively running, providing users with a visual indicator of new content even when the app is closed.


SwiftUI

Add the HubView to your SwiftUI TabView, define a tab item for it, and observe the Rover badge count to update the tab bar badge:

import RoverNotifications

/// An example of how to embed the Rover Hub in a SwiftUI tab.
struct ContentView: View {
    @ObservedObject var roverBadge: RoverBadge = Rover.shared.roverBadge

    var body: some View {
        TabView {
            // --- app's other tabs are here ---

            HubView()
                .tabItem {
                    Label("For you", systemImage: "person.circle.fill")
                }
                // Observe the Rover badge count and update the tab bar badge.
                .badge(roverBadge.newBadge)
        }
    }
}

UIKit

Add the HubHostingController to your UITabBarController, set up the tab bar item, and observe the Rover badge count publisher using Combine to update the tab bar badge:

import UIKit
import Combine
import RoverNotifications

class TabBarController: UITabBarController {
    private var cancellables = Set<AnyCancellable>()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Create the Hub hosting controller
        let hubController = HubHostingController()
        
        // Set up the tab bar item
        hubController.tabBarItem = UITabBarItem(
            title: "For You",
            image: UIImage(systemName: "person.circle.fill"),
            tag: 0
        )
        
        // Add other view controllers as needed
        viewControllers = [
            // --- app's other tab view controllers are here ---
            hubController
        ]
        
        // Observe badge changes using Combine
        Rover.shared.roverBadge.$newBadge
            .receive(on: DispatchQueue.main)
            .sink { [weak self] badgeValue in
                hubController.tabBarItem.badgeValue = badgeValue
            }
            .store(in: &cancellables)
    }
}
Previous
Live Activities