屏幕锁定时的 UILocalNotification 处理

发布于 2024-10-05 02:23:37 字数 402 浏览 15 评论 0原文

我正在开发一个 iPhone 应用程序,它使用 UILocalNotifications 在特定时间发送警报。按警报上的“确定”按钮将启动应用程序,以便它可以执行特定任务。

到目前为止,在大多数情况下,一切都运行良好:如果应用程序正在运行并且警报触发,则它可以正常工作,如果应用程序没有运行(但手机已打开),它也可以正常工作。

但是,如果在屏幕锁定时触发警报,则会发生以下两种情况之一。

  1. 警报触发,我立即“滑动解锁”,然后应用程序按预期启动。
  2. 警报触发,但我等待“滑动解锁”超过 20 秒(屏幕再次锁定(变暗)所需的时间)。当我最终解锁屏幕时,会显示警报,但不会启动应用程序。

我浏览了苹果文档和这个网站,但找不到答案。我希望我的解释有意义。有什么想法吗?

I am developing an iPhone app that delivers alerts at certain times using UILocalNotifications. Pressing the OK button on the alert launches the app so it can perform specific tasks.

So far, everything works beautifully in most cases: if the app is running and the alert fires, it works fine, and if the app is not running (but the phone is on), it works just as well.

However, if the alert fires when the screen is locked, one of two things happens.

  1. alert fires, and I "slide to unlock" immediately, then the app launches as expected.
  2. alert fires, but I wait to "slide to unlock" longer than 20 seconds (the time it takes the screen to lock (dim) again). When I finally unlock the screen, the alert shows, but does NOT launch the app.

I have looked throughout the Apple docs and this site, but cannot find an answer. I hope my explanation makes sense. Any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨后咖啡店 2024-10-12 02:23:37

我认为这种行为是有道理的,不应该被规避(我认为这是不可能的)。如果用户在收到通知后几秒就滑动解锁,则很有可能是因为该通知而滑动解锁并想要进入该应用。如果过了很长时间,该通知仍然会显示,但用户因该通知而滑动解锁的可能性较低。他更有可能只是想写一封电子邮件或做一些完全不同的事情。因此最后通知的应用程序不应启动。

I think that behaviour makes sense and shouldn't be circumvented (which I think is not possible). If the user slides to unlock just after a few seconds after the notification, the propability is high, that he slided to unlock just because of that notification and wants to get into the app. If a lot of time is passed, the notification is still shown, but the propability is low, that the user slides to unlock because of this notification. It is more likely that he just wants to write an email or do something completely different. So the app of the last notification shouldn't get started.

喜你已久 2024-10-12 02:23:37

感谢您快速而清晰的回答,多米尼克。快速跟进:重新启动应用程序的目的是安排另一个警报。如果我一次发送多个警报(安排在不同的时间),并且用户没有为其中任何一个警报解锁手机,那么在用户第一次解锁时,它们是否都会同时出现? (我只想出现最后一个)

再次感谢。

Thanks for your quick and clear answer, Dominik. Quick follow-up: the purpose in relaunching the app is to schedule another alert. If I send several alerts at once (scheduled for different times), and the user does not unlock the phone for any of them, do they all appear at the same time the first time the user unlocks? (I would only want the last one to appear)

Thanks again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文