This was driving me crazy but I finally found the fix to this issue:
I was setting the app's badge count in a ViewModel, but the push notification (I have a notification extension) was waking up the app and executing that code in background. If you set the app badge to 0 at some point, all notifications are removed from the lock screen.
Now I have:
private func updateAppBadgeIcon() {
let state = UIApplication.shared.applicationState
guard state == .active || state == .inactive else { return } /* Skips background update. */
UIApplication.shared.applicationIconBadgeNumber =	/* do your calculations for the badge */
}
Topic:
App & System Services
SubTopic:
Notifications
Tags: