Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to schedule a same local notification in swift

Tags:

ios

swift

I just want to schedule a same local notification in 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?

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

like image 923
Ankahathara Avatar asked Mar 18 '23 07:03

Ankahathara


1 Answers

UILocalNotification has a repeatInterval property that lets you specify how often the notification should repeat. 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.). See the NSCalendarUnit documentation for more options.

For example, you can make a notification repeat every month with:

notification.repeatInterval = .CalendarUnitMonth
like image 168
Greg Avatar answered Apr 01 '23 00:04

Greg