How can I update the badge on a tabview icon whenever a change to UIApplication.shared.applicationIconBadgeNumber occurs?
For instance, on a landing page where the number of unread messages are displayed:
struct LandingView: View {
@State private var selectedTab: SelectedTab = .home
var body: some View {
MessagesView()
.tabItem {
Label("Messages", systemImage: "envelope")
}
.tag(SelectedTab.requests)
.badge(UIApplication.shared.applicationIconBadgeNumber) // <- How to have changes to this value recompute the view?
HomeView()
.tabItem {
Label("Home", systemImage: "house")
}
.tag(SelectedTab.home)
}
}
}