How to clear the remote notification in your app?

前端 未结 8 1937
青春惊慌失措
青春惊慌失措 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:16

    You need to set the IconBadgeNumber to 0 and cancel the current notifications. I never did in swift but I think the code for it would be as bellow:

    application.applicationIconBadgeNumber = 0 
    application.cancelAllLocalNotifications()
    

    Swift 5

    UNUserNotificationCenter.current().removeAllDeliveredNotifications()
    

提交回复
热议问题