Clear app badge with local notifications

后端 未结 2 1526
醉酒成梦
醉酒成梦 2020-12-28 16:27

I\'m trying to clear my app\'s \"unread\" badge with a UILocalNotification. Logically you would think this would be done by setting applicationIconBadge

相关标签:
2条回答
  • 2020-12-28 16:47

    I had the same problem. When setting the badge from a local notification, setting it to 0 is the default for 'no change', while doing it straight from the application would clear it. Setting it to a negative number through a local notification solved the problem.

    try:

    clearEpisodeNotification.applicationIconBadgeNumber = -1;
    
    0 讨论(0)
  • 2020-12-28 16:54

    Yes, it is possible to clear the badge from the app itself.

    I use the code below in one of my apps, and it works as expected (i.e. clears the badge):

    //clear app badge
    [UIApplication sharedApplication].applicationIconBadgeNumber=0;
    
    0 讨论(0)
提交回复
热议问题