Clear notifications badge without removing notifications

后端 未结 3 793
情歌与酒
情歌与酒 2021-01-12 16:13

In my app, I\'m receiving push notifications with badge number set to one. When app will start, it should set badges count to 0, so I\'m using:

[[UIApplicat         


        
3条回答
  •  粉色の甜心
    2021-01-12 16:53

    With iOS9 directly setting badge to negative still clears notifications. You must fire empty UILocalNotification with negative badgenumber to achieve this.

    let ln = UILocalNotification()
    ln.applicationIconBadgeNumber = -1
    UIApplication.sharedApplication().presentLocalNotificationNow(ln)
    

提交回复
热议问题