A more SwiftUI-oriented approach might be to listen for changes in the @Environment(\.scenePhase) var scenePhase in the root view. Then, if the new phase is .active, set UIApplication.shared.applicationIconBadgeNumber to 0 as discussed by the other answers.
Example Code:
@main
struct MRPApp: App {
@Environment(\.scenePhase) var scenePhase
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
ContentView()
.onChange(of: scenePhase) { newPhase in
if newPhase == .active {
UIApplication.shared.applicationIconBadgeNumber = 0
}
}
}
}
}