在特定时间在 Iphone 中显示警报/通知(由用户或开发人员设置)
我想知道使用什么 IOS 功能来使我能够在 iPhone 上的特定时间显示警报/通知。用户或开发人员可以使用 UIDatePicker 设置时间。运行本地通知教程,警报/通知仅当应用程序位于后台时才会显示(如果我错了,请纠正我)
如果有人可以帮助我解决这个问题,那就太好了。
I would like to know what IOS functionality to use to enable me to display a alert/notification at a particular time on the iphone. The time would be set either by the user or the developer using the UIDatePicker. Running the Local Notification Tutorial, the alert/notification is getting displayed only when the app is in the background(please correct me if I am wrong)
It would be great if someone could help me out with this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所以我认为你在这里的方向是正确的:不确定我还可以添加什么。
您可以使用本地通知在任何给定时间显示警报。正如您从教程中看到的,当您的应用程序位于前台时,不会触发通知。
但是,没有什么可以阻止您在应用程序中编写代码,以便在应用程序位于前台时需要通知时提醒用户:这可能更理想。您可能希望利用在前台提供的 UI 选项来执行不同的操作,或者您可以只显示自己的 UIAlertView。
So I think you're on the right track here: not sure what more I can add.
You can use a local notification to display an alert at any given time. As you see from the tutorial, notifications aren't triggered when your app is in the foreground.
But there's nothing to stop you from writing code in your app to alert users at the time the notification is required when your app is in the foreground: and this is probably more ideal. You may want to take advantage of the UI options offered to you when in the foreground to do something different, or you could just display your own UIAlertView.
我可以给你我的简短代码来确定日期的具体时间......
我试图计算特定月份的时间。
示例(从 2011 年 1 月 1 日到 2011 年 1 月 2 日上午 0:0:00)。
在我住的地方,格林威治标准时间有 2 小时的时差。
//你会在调试器控制台上看到类似这样的内容:
//datePicker.date = 2011-01-01 08:42:16 GMT
//dategre = 2011-01-31 22:00:00 GMT(对我们来说,这等于 2011 年 2 月 1 日上午 0:00:00)
我希望我能帮助你,
再见,
威利。
I can give you my short code to put a specific time on date...
I was trying to calculate an specific month time.
Example (from 1-1-2011 to 2-1-2011 at 0:0:00 am).
Where I live, I have 2h of difference respect of GMT.
//You would see on debugger console something like this:
//datePicker.date = 2011-01-01 08:42:16 GMT
//dategre = 2011-01-31 22:00:00 GMT (for us, this is equal to 2-1-2011 at 0:00:00 am)
I hope I can help you,
bye,
Willy.