Badge Management

Manage the badge number that appears on your app icon, including manual control and automatic incrementing.

The badge appears as a number on your app icon. You can set, reset, or enable auto-badge functionality.

Get Badge Value

The badgeNumber property returns the current badge number used by both the device and the Airship server. This property must be accessed on the main thread.

Get badge number

let currentBadge = await Airship.push.badgeNumber
 Note

This async property is not available in Objective-C. Use UIApplication.shared.applicationIconBadgeNumber to read the current badge value.

Set Badge Value

Set the badge number to a specific value. This updates both the device badge and the value stored on Airship servers.

Set badge number

try await Airship.push.setBadgeNumber(20)
 Note

This async method is not available in Objective-C. Use UIApplication.shared.applicationIconBadgeNumber to set the badge value directly.

Reset Badge

Reset the badge to zero on both the device and Airship servers.

Reset badge

try await Airship.push.resetBadge()
 Note

This async method is not available in Objective-C. Set UIApplication.shared.applicationIconBadgeNumber = 0 to reset the badge directly.

Auto-Badge

Auto-badge automatically updates the badge number stored by Airship every time the app is started or foregrounded, instead of setting an exact value.

Enable auto-badge

Airship.push.autobadgeEnabled = true
UAirship.push.autobadgeEnabled = YES;
 Important

When using auto-badge, only modify the badge value through Airship methods to ensure the value stays in sync.