【问题标题】:How to schedule a same local notification in swift如何在swift中安排相同的本地通知
【发布时间】:2014-10-06 10:57:29
【问题描述】:

我只想在 Swift 中安排相同的本地通知。例如,我只想安排一条消息说“是时候计算本月的账单了”,我想在下个月再次发送同样的消息。

如何在 Swift 中做这种本地通知?

我参考了以下内容,但无法在下个月安排相同的消息...

//http://thecodeninja.tumblr.com/post/89942124085/notifications-in-ios-8-part-1-using-swift-what-is //From String to NSDate in Swift

【问题讨论】:

    标签: ios swift


    【解决方案1】:

    UILocalNotification 有一个repeatInterval 属性,可让您指定通知应重复的频率。请注意,这是一个NSCalendarUnit,而不仅仅是一个任意数字,因此您只能在每个日历单位(秒、分钟、小时、日、周、月等)中重复一次通知。请参阅NSCalendarUnit documentation 了解更多选项。

    例如,您可以通过以下方式每月重复一次通知:

    notification.repeatInterval = .CalendarUnitMonth
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-06
      相关资源
      最近更新 更多