iOS Setup

Inbox

Requires SDK 4.11.0 or later

The Rover Inbox (sometimes 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.

Communication Hub

This feature is identified as "CommunicationHub" in the API to distinguish it 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.


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

SwiftUI

import RoverNotifications

/// An example of how to embed the Rover Communication 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 ---

            CommunicationHubView(
                /// Optionally specify the Communication Hub's title bar text, if needed. It defaults to "Inbox".
                title: "Inbox",
            )
                .tabItem {
                    Label("Inbox", systemImage: "envelope.open")
                }
                // Observe the Rover badge count and update the tab bar badge.
                .badge(roverBadge.newBadge)
        }
    }
}

UIKit

Add the CommunicationHubHostingController 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 Communication Hub hosting controller
        let communicationHubController = CommunicationHubHostingController(
            /// Optionally specify the Communication Hub's title bar text, if needed. It defaults to "Inbox".
            title: "Inbox",
            // Optionally specify the accent color to use for buttons and links. It defaults to your app's accent color.
            accentColor: Color("Brand Accent Color")
        )
        
        // Set up the tab bar item
        communicationHubController.tabBarItem = UITabBarItem(
            title: "Inbox",
            image: UIImage(systemName: "envelope.open"),
            tag: 0
        )
        
        // Add other view controllers as needed
        viewControllers = [
            // --- app's other tab view controllers are here ---
            communicationHubController
        ]
        
        // Observe badge changes using Combine
        Rover.shared.roverBadge.$newBadge
            .receive(on: DispatchQueue.main)
            .sink { [weak self] badgeValue in
                communicationHubController.tabBarItem.badgeValue = badgeValue
            }
            .store(in: &cancellables)
    }
}
Previous
Push Notifications