Badges
Badges are small icons that are ideal for getting a user’s attention. You can specify a badge count in the Settings tab when you compose a push notification using Braze’s dashboard. You may also update your badge count manually through your application’s
applicationIconBadgeNumber
property or the remote notification payload.
Braze will automatically clear the badge count when a Braze notification is received while the app is in the foreground. Manually setting the badge number to 0 will also clear notifications in the notification center.
If you do not have a plan for clearing badges as part of normal app operation or by sending pushes that clear the badge, you should clear the badge when the app becomes active by adding the following code to your app’s applicationDidBecomeActive:
delegate method:
1
2
3
4
5
6
7
8
9
10
// For iOS 16.0+
let center = UNUserNotificationCenter.current()
do {
try await center.setBadgeCount(0)
} catch {
// Handle errors
}
// Prior to iOS 16. Deprecated in iOS 17+.
UIApplication.shared.applicationIconBadgeNumber = 0
1
2
3
4
5
6
7
8
9
10
// For iOS 16.0+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center setBadgeCount:0 withCompletionHandler:^(NSError * _Nullable error) {
if (error != nil) {
// Handle errors
}
}];
// Prior to iOS 16. Deprecated in iOS 17+.
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;