如何永久设置通知?

时间:2012-07-12 07:33:32

标签: ios notifications

我的应用程序是药物提示,许多客户要求我实现每天安排药物的可能性。

我知道应用程序可以设置的本地通知数量有限,那么设置此类提醒的好方法是什么?

1 个答案:

答案 0 :(得分:1)

在通知UILocalNotification *notification = [[UILocalNotification alloc]init];后,您需要设置通知的repeatInterval属性。

所以:

UILocalNotification *notification = [[UILocalNotification alloc]init];

...

notification.repeatInterval = NSDayCalendarUnit;

...

[[UIApplication sharedApplication] scheduleLocalNotification:notification];

注意:使用NSDayCalendarUnit通知会每天重复。如果你愿意,你可以使用其他常量来重复每周或其他任何事情。这个常量定义如下:

http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSCalendar_Class/Reference/NSCalendar.html#//apple_ref/doc/c_ref/NSCalendarUnit

因此,如果您需要其他重复间隔,您可能需要查看。