Freeman
Freeman

Reputation: 12728

How to show Notification in Swift more than once?

Is there anyway to show the notification with swift every 15 seconds ? I checked that via

notification.fireDate=NSDate(timeIntervalSinceNow: 15)

but it doesn't work everytime it just showed once , how we can do it as a loop ?

Upvotes: 0

Views: 243

Answers (2)

Leo Dabus
Leo Dabus

Reputation: 236380

You can't schedule a notification every 15 second. The minimum time between notifications it is 1 minute which it is also very unlikely needed.

var repeatInterval: NSCalendarUnit { get set }

Description The calendar interval at which to reschedule the notification. If you assign a calendar unit such as weekly (NSWeekCalendarUnit) or yearly (NSYearCalendarUnit), the system reschedules the notification for delivery at the specified interval. Note that intervals of less than one minute are not supported. The default value is 0, which means that the system fires the notification once and then discards it.

So just set it up as follow:

notification.repeatInterval = .Minute

Upvotes: 2

user4478383
user4478383

Reputation: 338

You can set localNotification.repeatInterval property which as to be of type NSCalendarUnit

Upvotes: 0

Related Questions