It’s really common for apps that support notifications to use them to update the application badge to display numbers of unread messages, undone tasks, etc. But what if you don’t need or want the added complexity of supporting push notifications, or even local notifications, but want to alert the user via an app badge?
Apple’s documentation on this particular way of using app badges is not the best. Badges are combined with the UserNotifications framework, but if you want to set the badge yourself outside of a notification, that is part of UIKit. And the documentation are missing important points like: do you need to check that you’re authorized to show badges to set the badge manually? Will it error out? Crash? Result in strange app behavior?
Manual app badges turn out to be really easy, but the docs don’t make it seem that way. Let’s demystify them right now.