保持UNNotificationContent几秒钟 [英] Keep UNNotificationContent some seconds

查看:128
本文介绍了保持UNNotificationContent几秒钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iOS 10的Swift 3开发一个应用程序.我已经完成了UNNotificationContent来模拟应用程序中的通话,但是在启动大约五秒钟后它消失了.在调用"过程中,我需要将其保留几秒钟.我想保留本地通知,直到调用removeAllPendingNotificationRequests方法.我可以吗?

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?

现在这是我的代码:

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)

谢谢!

推荐答案

无法控制通知在屏幕上停留多长时间.这是由系统控制的.

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

这篇关于保持UNNotificationContent几秒钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆