0

How to solve this problem? Please help me.

I used the following code in my project, but can't delete notification.

if #available(iOS 10.0,  {

let center = UNUserNotificationCenter.current()

center.removeDeliveredNotifications(withIdentifiers: [String(self.chatRoom.getChatRoomID())])
} else {
// Fallback on earlier versions
}
var app:UIApplication = UIApplication.shared
for oneEvent in app.scheduledLocalNotifications! {
var notification = oneEvent as UILocalNotification
let userInfoCurrent = notification.userInfo! as! [String:AnyObject]
let uid = userInfoCurrent["TeamChatRoomID"]! as! String
if uid == String(self.chatRoom.getChatRoomID()){
//Cancelling local notification
app.cancelLocalNotification(notification)
break;
}
}
Manohar
  • 41
  • 1
  • 9

1 Answers1

0

To clear all the notification from notification center

ios>10: https://developer.apple.com/documentation/usernotifications/unusernotificationcenter

ios<10: setting application badge number to 0 should do the trick

But I am not sure if this is what you are looking for, as the question is unclear.

Luzo
  • 1,336
  • 10
  • 15