0

I have an app where I am using apple push notifications. Now I need to show the badge number depending upon the notifications, and I also need to decrease the badge number accordingly. I know this method is used for showing badge, but I am getting how to implement it.

 [UIApplication sharedApplication].applicationIconBadgeNumber = badgeNumer;

Can anyone help me with this?

Adrian Toman
  • 11,316
  • 5
  • 48
  • 62
user2174560
  • 139
  • 1
  • 2
  • 7

2 Answers2

0

You can use your code inside this method to show badge number.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
Vinodh
  • 5,262
  • 4
  • 38
  • 68
0

It will show until you set it to zero and you can do it with the following code:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]

It is more common to set the badge number as you receive the notification, in either application:didReceiveRemoteNotification: or application:didFinishLaunchingWithOptions: methods of your UIApplicationDelegate class.

You can read more about it in the Local and Push Notification Programming Guide

Amit Singh
  • 2,644
  • 21
  • 20
  • 2
    How does it differ from below link. Just copy & paste. http://stackoverflow.com/questions/6424938/apple-push-notification-badge-number/6424962#6424962 – Piyush Dubey May 14 '14 at 09:45