【问题标题】:Save Local Notification in ios在 ios 中保存本地通知
【发布时间】:2015-10-13 11:15:49
【问题描述】:

如何保存本地通知?我想再次使用本地通知触发日期来安排本地通知。

【问题讨论】:

  • 不明白你想要什么。发布一些代码或详细说明。
  • 为什么要在同一日期再次触发通知?你的问题很难理解。
  • 我的目的是使用相同的触发日期,但在特定日期更改重复间隔或操作。
  • 致 Hugues BR:您的回答并不完全符合我的要求……但我使用了另一种方法来解决我自己的问题。我仍然感谢您的帮助!

标签: ios objective-c nsdate uilocalnotification


【解决方案1】:

你应该使用UILocalNotification

请查看文档:https://developer.apple.com/library/ios/documentation/iPhone/Reference/UILocalNotification_Class/

它看起来像:

UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = dateTime;
localNotification.alertBody = [NSString stringWithFormat:@"Alert Fired at %@", dateTime];
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

关于通知重新安排周期:

触发通知不足以显示另一个通知。除非用户点击通知,否则您的应用不会启动。 您可以为下个月的每一天或每周预先安排一个通知,并在用户打开通知时取消安排。根据您的需要,您还可以使用content-available 键触发remote notification,这将在后台启动您的应用程序并允许您重新安排新的本地通知。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-17
    • 1970-01-01
    相关资源
    最近更新 更多