Page updated Nov 14, 2023

Add app badge count

The app badge count, when set, can be seen on your app's icon on a user's device. Amplify provides you with simple helpers to manipulate this number.

App badge count helpers are safe to call (but will be ignored) even when your app is running on platforms where badges are not supported.

Get the current badge count

Use getBadgeCount to get the current app badge count. You might need to do this to calculate the value when setting the badge count.

1import {
2 getBadgeCount,
3 GetBadgeCountOutput
4} from 'aws-amplify/push-notifications';
6const count: GetBadgeCountOutput = await getBadgeCount();
1import { getBadgeCount } from 'aws-amplify/push-notifications';
3const count = await getBadgeCount();

Update the badge count

Use setBadgeCount to set the current app badge count. Setting the badge count to 0 (zero) will remove the badge from your app's icon.

1import {
2 setBadgeCount,
3 SetBadgeCountInput
4} from 'aws-amplify/push-notifications';
6const count: SetBadgeCountInput = 42;
1import { setBadgeCount } from 'aws-amplify/push-notifications';
3const count = 42;