Non-Numeric App Badges on iOS
If you’ve spent any time at all on iOS, you’re already familiar with App Badges, the red circle on the top-right corner of an app icon that reflects some important count within the app, like the number of items in a todo list, or the number of unread messages you have waiting for you:
You can set this value manually using UIApplication.applicationIconBadgeNumber
, or update it as part of a
local
or remote
notification.
But why does it have to always be a number?
In fact, if you’ve looked closely (and have an occasionally-spotty internet connection), you may have already seen an indication that this doesn’t have to be the case, in the form of iMessage’s error badge when a message fails to send:
This is made possible by a private method on UIApplication
, a
sibling of the public applicationIconBadgeNumber
property:
@interface UIApplication (Private)
// Sets the App Badge to the given string.
// Hides the App Badge if `badgeString` is `nil`.
- (void)setApplicationBadgeString:(NSString *)badgeString;
@end
Calling this method allows for you to show any arbitrary text alongside your App Icon:
Of course, we’re not limited to just ASCII characters — we can make things more interesting by adding emoji as well. I’ve decided to follow this to its logical conclusion and have therefore built a quick app that experiences the five stages of grief when you move it to the background:
While this particular example has… limited use cases, emoji badges in general could definitely be used in some interesting ways, especially in places where you want to quickly convey a message or status right on the home screen.
Just keep in mind that, as is always the case with private APIs, you should only use this in a personal application or in a build that won’t be shipped to the App Store. That might be for the best — one app with emoji badges sounds useful, while forty sounds absolutely terrifying.
Say Hello!