adjust main app badge count when push notification arrives in background?

does anyone know an in-app way we can intercept the incoming push notifications when app is backgrounded or inactive

and adjust the badge count that gets put on the app icon?


the situation is that we have a notification service sending us notifications, but it is only taking into account the unread

count from itself, and we want to take into account "other sources of un-read" data in our app when we put up that app badge.


it is fixable when we put the app back into the background after using it for a while, but once app is in background,

the notification service is overwriting out carefully constructed badge integer when a push comes in.


i found this doc about employing an app extension, but it seems kind of complicated:


https://developer.apple.com/documentation/usernotifications/modifying_content_in_newly_delivered_notifications?language=objc

I'm looking for a similar solution, I need to take the count I get from a service and add it to another count I've stored in UserDefaults.

adjust main app badge count when push notification arrives in background?
 
 
Q