我正在创建简单的 UILocalNotification
,没有调度,只是从后台使用以下代码:
let n = UILocalNotification()
n.alertBody = "\(nam) \(wat)"
n.userInfo = ["id": id, "t":type.rawValue]
n.soundName = UILocalNotificationDefaultSoundName
n.category = "call_chat"
app.scheduleLocalNotification(n)
我正在打印 userInfo
func application(_ application: UIApplication, didReceive notification: UILocalNotification)
到这里一切都很好。但是我需要稍后关闭一些具有相同 ID 的通知并创建新的通知。当我试图通过 UIApplication.shared.scheduledLocalNotifications
获取它们时,它们在 iOS9 和 userInfo==["":""中都有
在 iOS10 测试版中。userInfo==nil
]
最佳答案
所以,最后我发现,scheduledLocalNotifications 不包含已经显示的通知。唯一的方法是将它们存储在数组中,或者像 here 这样使用 NSKeyArchiver
.
关于ios - UILocalNotification 的 UserInfo 始终为 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38961266/