4

有什么方法可以创建在 iOS 中无法关闭的通知?它甚至可以是一种解决方法(例如,监听要清除的通知并在此之后显示一个新通知)。

4

2 回答 2

3

不,你可以安排一堆通知,但那是不同的。无法收听通知何时被关闭、将其保留在屏幕上或执行任何更改其性能的操作,因为这一切都是在您的应用程序之外处理的。

于 2013-09-22T14:32:53.307 回答
0

我发现如果你使用旧的 API,通知不会消失。

我使用了 iOS 10 之前的 API,它可以工作。

let notification = UILocalNotification()
notification.fireDate = Date().addingTimeInterval(10) // post after 10 seconds
if #available(iOS 8.2, *) {
    notification.alertTitle = "Title"
}
notification.alertBody = "Your message"

notification.soundName = UILocalNotificationDefaultSoundName
UIApplication.shared.scheduleLocalNotification(notification)

在 iOS 12.1 上进行了测试,通知没有消失。如果我要使用UNMutableNotificationContent通知将消失。

于 2018-11-13T07:09:10.973 回答