Control App Badging

Available InVersion
MobilePush SDK for iOS7.x and newer

SDK and iOS Badging 

When the SDK Sets the Badge 

The MobilePush SDK automatically sets the application badge value if inbox messaging is enabled in your SDK configuration. The SDK sets the badge in the following cases:

  • When an inbox message is sent from Marketing Cloud Engagement, a silent push is also sent. The silent push contains a badge value that reflects the system’s count of unread inbox messages.
  • When Engagement sends an Alert + Inbox message, the alert (push notification) includes a badge value. This badge value represents the total count of unread inbox messages, with an additional increment for the current push notification.
  • When the application is sent to the background, the MobilePush SDK sets the badge value to the count of unread inbox messages.

When iOS Sets the Badge 

When a push notification created in Engagement has a badge value enabled, iOS sets the application badge directly.

Neither the SDK nor the application can prevent this badge value from being set via a push notification.

Important

Application Badging Override 

Your application can override the SDK’s default badge setting. After you’ve configured your application to manage badging, the MobilePush SDK no longer updates the badge count based on the unread Inbox messages.

Configure 

To enable your application to manage badge control, set setApplicationControlsBadging(true) on the PushConfigBuilder during the SDK configuration.

10.x or higher
1let pushFeatureConfiguration = PushFeatureConfigBuilder()
2    .setApplicationControlsBadging(false)
3    .build()
8.x or 9.x
1let mobilePushConfiguration = PushConfigBuilder(appId: appId)
2    .setAccessToken(accessToken)
3    .setApplicationControlsBadging(true)
4    .build()
7.x
1let builder = MarketingCloudSDKConfigBuilder()
2    .sfmc_setApplicationId(appID)
3    .sfmc_setAccessToken(accessToken)
4    .sfmc_setApplicationControlsBadging(true)
5    .sfmc_build()!

Setting and Clearing the Badge 

If your application manages badging, we recommend updating or resetting the badge value in response to changes in events or data within your app.

You can adjust the badge value by setting it to an integer value.

1// example: set the badge to a user’s "points"
2application.applicationIconBadgeNumber = user.points
3
4// example: clear the badge when app comes to foreground
5func applicationDidBecomeActive(_ application: UIApplication) {
6    application.applicationIconBadgeNumber = 0
7}