iOS Badging and Auto Badging

When you update a device's badge count, use the methods provided by the Airship SDK to ensure the device token's registration is in sync with the client application. 

You can then update the device's badge number easily, via push request calls made from either the Airship Dashboard or the API.

App Implementation

To enable auto badging in the client application add the following call in the UPushNotificationDelegate method of your presentationOptions. Here's the method to use in Swift.

Airship.push.autobadgeEnabled = true

Here's the method to use in Objective-C.

UAirship.push.autobadgeEnabled = YES;

 

Auto badge allows incrementing the badge from a push instead of setting the exact value for the badge. When using auto-badge, make sure to only modify the badge value through Airship methods to ensure the value keeps in sync.

 

When a badge value is present, it will update the local application badge number to that which was received if autobadge is enabled. Otherwise it expects your own handler to do this along with any additional handling you implement.

Resetting Badge Value:

A typical application will reset the badge any time a user starts the app or resumes it from the background. This can be done by making UAPush resetBadge calls from application:didFinishLaunchingWithOptions: and applicationDidBecomeActive.

Airship.push.resetBadge()

You may be wondering why the device registration is not updated as soon as we parse the request payload specifying the new badge value. Auto badging only updates from the client library to ensure that the device's stored badge number does not differ from that which is registered for the device in Airship's database. Pushes do not always reach the device, whether it be deliberate or an issue from APNS. If Airship does not wait for the client to update the badge as a result of receiving the remote notification, the client badge values may become out of sync.

 

Setting badges from the Web Message Composer:

Please see the Message Composer guide for details.

Setting badges from the API:

Please review the iOS Object Override section of our Push API documentation for details on making calls to our Push API that change the badge value.

Related Content

Was this article helpful?
0 out of 1 found this helpful
Submit a request