Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apple push notification badge number

I have developed server side application to maintain the badge number as increment or decrement after receiving new notification and delete after seeing notification it works fine.

But there is some problem in showing the badge, the actual scenario is - After getting new notification on device, I am click on cancel button then badge number shows correctly but after that I will open the application and close the application badge will be removed. That means I am not sending request to the server that notification was seen by me and now you can decrement the badge by one. Then also badge removed from app icon.

My question is that when we open the application then badge number automatically removed from (application) device? or it will shows as it is until we set to zero?

like image 398
Amit Avatar asked Jun 21 '11 12:06

Amit


People also ask

How do I get my app icon to show notification numbers?

If you want to change badge with number, you can be changed in NOTIFICATION SETTING on the notification panel or Settings > Notifications > App icon badges > Select Show with number.

Why are my badges not showing numbers?

If the badges are not displaying, you'll need to enable the notifications for that app and then turn on the app icon badges. Icon badges are only natively supported by the One UI Home launcher. If you are using an alternative launcher, badges may not be supported.

Why are my app badges not showing numbers iPhone?

Check Settings app On your iPhone or iPad, leave Things and go to the Settings app. Tap Notifications. Scroll down to find Things and tap it. Enable the toggle for Badges (if it's already on, toggle it off and back on).


1 Answers

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

    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]


EDIT:
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

like image 141
Felipe Sabino Avatar answered Oct 03 '22 23:10

Felipe Sabino