Keep UNNotificationContent some seconds

╄→гoц情女王★ 提交于 2019-12-24 08:58:51

问题


I'm doing an app in Swift 3 for iOS 10. I have done an UNNotificationContent to simulate a call in my app but it disappears approximately five seconds after being launched. I need to keep it more seconds, while the "calling" is in process. I want to keep the local notification until I call the removeAllPendingNotificationRequests method. Can I do it?

This is my code now:

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)

Thanks!


回答1:


There's no way to control how long the notification stays on the screen. That's controlled by the system.



来源:https://stackoverflow.com/questions/40346256/keep-unnotificationcontent-some-seconds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!