【发布时间】:2018-08-04 07:13:22
【问题描述】:
如何解决这个问题?请帮帮我。
我在项目中使用了以下代码,但无法删除通知。
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;
}
}
【问题讨论】:
-
你试过This吗?
-
@Ketan Odedra:见上面我正在使用的代码。