- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚对 iOs 10 和其他版本的通知进行了更改:
if #available(iOS 10.0, *) {
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .sound]) { (granted, error) in
let content = UNMutableNotificationContent()
content.body = notifMessage!
content.sound = UNNotificationSound.default()
// Deliver the notification in five seconds.
let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 5, repeats: false)
let request = UNNotificationRequest.init(identifier: "Upload", content: content, trigger: trigger)
// Schedule the notification.
let center = UNUserNotificationCenter.current()
center.add(request)
}
} else {
let notification = UILocalNotification()
notification.alertBody = notifMessage
notification.fireDate = NSDate() as Date
notification.soundName = UILocalNotificationDefaultSoundName
UIApplication.shared.scheduleLocalNotification(notification)
}
当我通过将设备与 USB 连接来在设备上运行应用程序时,它可以工作,但只有当应用程序处于后台时,它才不会在以下情况下工作:
我杀死了应用程序
当应用程序显示时
最佳答案
如果您终止该应用程序(通过双击主页按钮然后向上滑动),这不仅会终止该应用程序,还会禁止该应用程序的进一步后台操作(直到用户再次启动它)。您只需按主页按钮,然后通过正常的内存恢复过程就可以放弃该应用程序。或者,出于测试目的,您可以以编程方式使应用程序崩溃。但是您不能使用跳板(双击主页按钮技巧),因为会影响应用程序允许的背景模式。
关于显示应用程序时的通知、用户点击通知以及用户手动启动应用程序而忽略通知,这些都以不同的方式传达给应用程序。请参阅 UIApplicationDelegate
documentation 的响应通知和事件部分。或者参见App Programming Guide for iOS: Background Execution有关后台操作的一般信息。
关于swift - 应用程序被终止时 UNUserNotificationCenter 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41614386/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!