我正在为 iOS 10 在 Swift 3 中做一个应用程序。我已经做了一个 UNNotificationContent 来模拟我的应用程序中的呼叫,但它在启动后大约五秒钟消失了。我需要保持更多秒,而“呼叫”正在进行中。我想保留本地通知,直到我调用 removeAllPendingNotificationRequests 方法。我可以做吗?
这是我现在的代码:
let content = UNMutableNotificationContent()
content.body = "\(userName) is calling..."
content.sound = UNNotificationSound(named: "sound_call.wav")
content.badge = 1
let request = UNNotificationRequest(identifier: "notification", content: content, trigger: nil)
UNUserNotificationCenter.current().add(request)
谢谢!