Senorina
Senorina

Reputation: 231

Removing the badge number when local notification is canceled

I'm developing a reminder app. I'm using local notification. It is working fine. But a badge number is always showing on top of my app's icon. How can I remove the badge number after firing the local notification? When I put [UIApplication sharedApplication].applicationIconBadgeNumber = 0; in did finish launching, the badge number is completely removed.

Upvotes: 5

Views: 7938

Answers (3)

Sosily
Sosily

Reputation: 726

i try the same thing and i found this:

When the app in in the background and you try to set the LocalNotification to 0 it will not remove the IconBadgeNumber. you need to set the IconBadgeNumber to -1.

    UILocalNotification *localSilentNotif;
    localSilentNotif.applicationIconBadgeNumber = -1;

Upvotes: 2

Srinivas
Srinivas

Reputation: 983

Whenever The Notification Fired In App delegate didReceiveLocalNotification Method Fired You Can Decrease The Count By One And Add One When You Add New Notification.

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

    [UIApplication sharedApplication].applicationIconBadgeNumber=application.applicationIconBadgeNumber-1;
}

Cheers

Upvotes: 6

EmptyStack
EmptyStack

Reputation: 51374

I guess that you are trying to remove the badgeNumber from the badge icon and show only an empty(without any number) badge icon. You can not just remove the badge number alone from the badge icon. If you set applicationIconBadgeNumber to 0, the badge icon itself will be removed from the application icon.

If the badge to be shown then there should be a number, not a 0. 0 is inteneted to remove the badge icon.

Upvotes: 6

Related Questions