我怎样才能实现Apple的“Snooze”功能?他们的时钟应用程序中的功能?
我正在深入研究 iOS 开发,并正在构建自己的闹钟应用程序以熟悉该平台和 SDK。我目前正在学习的 API 之一是本地通知 API,我认为它与 Apple 用于在时钟应用程序中实现闹钟的 API 相同。
我不明白的是他们如何实现“贪睡”功能。据我了解,本地通知允许您向用户呈现一个警报框,当您的应用程序未在前台运行时,该警报框最多有两个按钮,一个按钮用于消除警报,一个按钮用于将用户带到您的应用程序。然而,在苹果的时钟应用程序中,用户似乎会看到一个带有两个按钮的警报框,一个按钮用于关闭闹钟,一个按钮用于“暂停”并重新安排闹钟,而无需启动时钟应用程序。我的问题是...
当用户单击“暂停”按钮时,您认为 Apple 如何在不启动时钟应用程序的情况下重新安排闹钟的本地通知?您是否认为他们正在使用自己的私有 API 来规避本地通知仅允许两个选项的限制?或者您认为他们启动时钟应用程序是为了重新安排本地通知,只是不显示应用程序的启动和退出?
文档中说本地通知的“alertAction”属性是在警报框的右侧按钮和锁定屏幕的滑块上显示的文本。然而,在苹果的时钟应用程序中,“贪睡”文本是警报框中的左侧按钮,也不是滑块栏文本。为什么会这样?
预先非常感谢您的想法!
I'm diving into iOS development and am building my own alarm clock app to become familiar with the platform and SDK. One of the API's I'm currently learning is the Local Notifications API, which I assume is the same API Apple uses to implement their alarms in their Clock app.
What I don't understand is how they implement their "Snooze" functionality. As I understand it, Local Notifications allow you to present to the user an alert box that has at most two buttons when your app isn't running in the foreground, one button for dismissing the alert and one button for taking the user to your app. In Apple's Clock app, however, it appears the user is presented with an alert box with two buttons, one button to dismiss the alarm and one button to "Snooze" and reschedule the alarm without launching the Clock app. My questions are...
When the user clicks the "Snooze" button, how do you think Apple is rescheduling the Local Notification for the alarm without launching the Clock app? Do you think they're using their own private APIs that circumvent the limitations of the Local Notifications that only allow for two options? Or do you think they're launching the Clock app to reschedule the Local Notification, they just don't show the app launching and quitting?
The documentation says the "alertAction" property of the Local Notification is the text to be displayed on the right button of the alert box and the slider bar of the lock screen. In Apple's Clock app, however, the "Snooze" text is the left button in the alert box, nor is it the Slider bar text. Why is this backwards?
Thanks so much in advance for your thoughts!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
本地通知 API 没有任何机制来执行您想要的操作。闹钟应用程序几乎肯定不会使用任何本地通知基础设施,它早于它们。即使它被纳入本地通知提供的一些基础设施中,它也肯定不会使用公共 API。
您应该提交错误,请求添加此功能。
The local notification API does not have any mechanism to do what you want. The alarm clock app is almost certainly not using any of the infrastructure for local notifications, it predates them. Even if it is factored onto some of the infrastructure provided by local notifications, it is certainly not using the public APIs.
You should file a bug requesting that this functionality be added.