Prior to iOS 8, scheduling weekly repeating notifications was easy, we just assigned NSWeekCalendarUnit
to the notification.repeatInterval
value. Now with iOS 8, pretty much all the NSCalendarUnit
values have been deprecated and replaced, mostly so Apple could rename them from NSDayCalendarUnit
to NSCalendarUnitDay
for consistency. However, they changed NSWeekCalendarUnit
into NSCalendarUnitWeekOfMonth
and NSCalendarUnitWeekOfYear
, with no clear explanation of what the difference is, and the UILocalNotification
documentation still talks in terms of the deprecated values.
I want a UILocalNotification
to repeat every 7 days. I assumed NSCalendarUnitWeekOfMonth
was the correct value, but when I use it, I get no repetition. Testing is time consuming, because each test takes a week!
Does anyone know which of the new week calendar units should be used for a weekly repeating local notification, or should the deprecated values continue to be used despite the warnings?
Assuming Gregorian Calendar, it seems NSCalendarUnitWeekOfYear
is value either from 1 - 53
or 0 - 52
which represents number of week within the calendar year. NSCalendarUnitWeekOfMonth
is 1 - 5
or 0 - 4
which represents week within the month (Undocumented stuff, these are personal opinions ).
In my experience i found NSCalendarUnitWeekOfYear working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With