Priyank Gandhi
Priyank Gandhi

Reputation: 1253

Clear Application's badge Number

I have made local notification in iphone app. And set icon badge number.

All works good. But if i have two notification in tray and user clicks on clear button than notification deletes from tray.

But the badge number of icon remains same.

I want to set the badge number to zero.

Thanks.

Upvotes: 13

Views: 13372

Answers (3)

Kevin ABRIOUX
Kevin ABRIOUX

Reputation: 17715

For Swift3, you can clear badge number in your application didFinishLaunchingWithOptions with this line :

UIApplication.shared.applicationIconBadgeNumber = 0

You can used this line in anywhere in code if you want too.

Upvotes: 4

Vishnu
Vishnu

Reputation: 354

use this in application didfinshlaunchingwithoptions

        application.applicationIconBadgeNumber = 0;

Upvotes: 10

Rushi
Rushi

Reputation: 4500

What you want to achieve is only possible using the Server Notifications. You can not set badge number locally without opening the application. As you won't have any control when user clears the tray. There's no way you can set the badge count at that moment.

Upvotes: 3

Related Questions