【问题标题】:How to cancel or delete on my lock screen after seen UILocalNotification in swift3?在swift3中看到UILocalNotification后如何在我的锁定屏幕上取消或删除?
【发布时间】: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:见上面我正在使用的代码。

标签: ios swift3


【解决方案1】:

清除通知中心的所有通知

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

ios 将应用程序徽章编号设置为 0 应该可以解决问题

但我不确定这是否是您要寻找的,因为问题不清楚。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-19
    • 1970-01-01
    • 1970-01-01
    • 2015-11-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多