How to clear the remote notification in your app?

前端 未结 8 1853
青春惊慌失措
青春惊慌失措 2021-02-04 03:01

Is there a way to clear the remote notification from the notification banner when swiping down from the top of the iPhone screen. I tried setting the badge number to zero:

相关标签:
8条回答
  • 2021-02-04 03:33

    Swift 4 & 5

    import UserNotifications
    
    ...
    ...
    ...
    
    UNUserNotificationCenter.current().removeAllDeliveredNotifications()
    
    0 讨论(0)
  • 2021-02-04 03:35

    any one looking for swift 4 and above code

    application.applicationIconBadgeNumber = 0
    UNUserNotificationCenter.current().removeAllDeliveredNotifications()
    
    0 讨论(0)
提交回复
热议问题