Can't clear the notification center without the aps = 0 icon or icon?

I push the notification payload to the user without the icon or icon = 0, the notification cannot be deleted from the Notification Center. Here is my payload:

{ "aps" : {"alert" : "bala bala"} //or "aps" : {"alert" : "bala bala", "badge" : 0} } 

Then open the application from NC, notification of stay in NC cannot be deleted. If I set the icon value to more than 0 in aps, the notification will be deleted after the application starts.

 { "aps" : {"alert" : "bala bala", "badge" : 1} } 

I have already installed [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; after starting the application.

Why can't a notification be deleted without the icon or icon = 0?

Thanks.

+4
source share
3 answers

I had the same problem. The solution is quite simple: Set the icon to 1 first and then 0. This should clear the notifications from the NC.

 [[UIApplication sharedApplication] setApplicationIconBadgeNumber:1]; [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; // Now the notification should be cleared out of the NC 
0
source
Icon

equal to 0, this means do not change. therefore you must set -1 for the icon.

 [[UIApplication sharedApplication] setApplicationIconBadgeNumber:-1]; 
0
source

From: iOS 5 Release Notes

  • Push and local notifications for applications are displayed in the new notification Center in iOS 5. The notification center displays notifications that are considered "unread". To place push and local notifications that do not have unread status, set the number of icons of your applications to 0; clear application notifications from the Notification Center.

So, the solution is to set the application icon to 0 when the application is open.

0
source

Source: https://habr.com/ru/post/1444565/


All Articles