I have a Notifications Tab in my TabBarController that I would like to show the same badge count as the App badge count. I have it working in all scenarios except for when the app is in the foreground.

To do this I've created a custom class for my TabBarController which registers for the UIApplicationWillEnterForeground notification and sets the Notification tab's badge to equal the App badge. I also do this in the OnLoad() function.

Now how do I make the Notification Tab badge update when the app is already in the foreground? I capture the notification in the AppDelegate function:

    application(_:didReceiveRemoteNotification:fetchCompletionHandler:)

I know it may be possible to dig around the rootViewController to find the tab bar controller but my root controller is a my entry point to the app which checks if the user has a login token in the keychain and segues to either the login view controller or tab bar controller. So given that it segues I'm not sure this is an option?

Is it possible for my UI to register for a 'push notification' notification like the way I register to by notified of UIApplicationWillEnterForeground? This would be ideal but I haven't managed to find such a notification.

Any advice or tips would be appreciated!

Related posts

Recent Viewed