iPhone:精确定时的闹钟或提醒
iPhone 应用程序内精确定时的闹钟或警报有哪些选项(如果有)? 我的应用程序可能需要在 30 秒或 5 小时 23 秒内提醒用户。
我假设对于较短的时间我可以只使用 NSTimer,但是在应用程序内触发计时器的截止点(如果有的话)是多少?
对于较长时间的警报或警报,我注意到提到了推送通知,它们可以定时到秒吗?它们可靠吗?还有其他选择吗?
What are the options(if any) for precisely timed alarms or alerts from within an iphone app?
My app may need to alert the user in 30 seconds or 5 hours and 23 seconds.
I assume for shorter times I could just use NSTimer, but what is the cutoff point(if there is one) for a timer to be fired within the app?
For longer timed alarms or alerts I've noticed push notifications have been mentioned, can they be timed to the second, are they reliable? Are there other options?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想要 本地通知。它们易于使用,并且不需要服务器。您只需 设置它们,无论您的应用程序是否打开,它们都会稍后触发。
请注意,这将需要 iOS4
另外,我相信您的警报可能会出现一个 60 秒的窗口,并且您可能无法精确控制它们何时出现。虽然我自己还没有测试过。
You want Local Notificaitons. They are easy to use, and require no server. You simply set them up, and they fire later wether your app is open or not.
Note that this will require iOS4
Also I believe there is a 60 second window your alert may appear in and you probably dont have percise control down to the second about when they appear. Though I haven't tested this myself.
查看本地通知。您可以使用 NSDate 来安排这些活动,例如,它允许您以从当前时间开始精确到秒的间隔安排警报。
看:
本地和推送通知
Take a look at local notifications. You may schedule these using NSDate, which, for example, allows you to schedule an alert in an interval with a precision down to seconds from the current time.
See:
Local and Push Notifications