每天在设定时间发送本地通知

时间:2012-07-19 08:03:55

标签: iphone uilocalnotification

我的要求很简单:我如何设置每天在设定时间给用户的本地通知?因此,例如,在9a.m发送通知。每一天。

我试过环顾四周但似乎没有我想要的东西。他们似乎都使用拣选员,而且我没有足够的经验与Obj-C一起工作。

感激不尽。

3 个答案:

答案 0 :(得分:0)

让NSTimer在后台运行,间隔为60秒。获取每分钟的当前时间。如果当前时间等于上午9点,则显示本地通知。

答案 1 :(得分:0)

UILocalNotification有一些属性,例如repeatIntervalfireDate 帮助你。

http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Reference/UILocalNotification_Class/Reference/Reference.html

但请注意,因为你有一些限制。检查一下:

UILocalNotification Repeat Interval for Custom Alarm (sun, mon, tue, wed, thu, fri, sat)

答案 2 :(得分:0)

使用NSDateComponents并将它们设置为fireDate似乎可行。使用repeatInterval重复该操作。

相关问题