简体   繁体   English

如何在swift中安排相同的本地通知

[英]How to schedule a same local notification in swift

I just want to schedule a same local notification in Swift. 我只想在Swift中安排相同的本地通知。 For example I just want to schedule a message saying "It's time to calculate your bill for this month" and I want to send this same message again next month. 例如,我只想安排一条消息,说“现在是时候计算本月的账单了”,我想在下个月再次发送同样的消息。

How to do this kind of local notification in Swift? 如何在Swift中进行这种本地通知?

I have referenced followings but was not able to schedule a same message in next month ... 我引用了以下内容但未能在下个月安排相同的消息...

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

UILocalNotification has a repeatInterval property that lets you specify how often the notification should repeat. UILocalNotification具有repeatInterval属性,允许您指定通知重复的频率。 Note that this is an NSCalendarUnit , not just an arbitrary number, so you can only make a notification repeat once per calendar unit (second, minute, hour, day, week, month, etc.). 请注意,这是一个NSCalendarUnit ,而不仅仅是一个任意数字,因此每个日历单位(秒,分钟,小时,日,周,月等)只能重复一次通知。 See the NSCalendarUnit documentation for more options. 有关更多选项,请参阅NSCalendarUnit文档

For example, you can make a notification repeat every month with: 例如,您可以通过以下方式每月重复通知:

notification.repeatInterval = .CalendarUnitMonth

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM