具有重复一次行为的UILocalNotification,如消息应用程序中

时间:2015-05-05 10:34:14

标签: ios cocoa-touch ios8 uilocalnotification

我有简单的UILocalNotification

UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = @"Message";
notification.alertAction = @"Action";
notification.soundName = UILocalNotificationDefaultSoundName;
notification.category = kCategoryIdentifier;

[[UIApplication sharedApplication] presentLocalNotificationNow:notification];

是否有可能重复一次通知,例如两分钟后?我希望行为卓越,就像在消息应用程序中一样。

我试图设置通知对象的repeatInterval属性,但是:

  • 通知将每两分钟呈现给用户,不会重复一次
  • 系统向用户显示新通知,不重复旧通知。用户看到两个通知,一个带有时间戳,接着是2分钟。

这不是我所期望的。

此外,由于第二个原因,我不想安排两个单独的通知。

编辑:在我的应用程序时间发生的事情非常重要。因此,在锁定屏幕中,当重复通知时,我希望用户知道这是先前发生的事情,而不是通知到达时。所以重复通知应该有第一次通知的时间戳。< / p>

1 个答案:

答案 0 :(得分:0)

是的,您可以设置repeatInterval。

请参阅文档here

  

重新安排通知的日历间隔。

     

宣言SWIFT
var repeatInterval: NSCalendarUnit
目标-C
  @property(nonatomic) NSCalendarUnit repeatInterval