12

I'm using UILocalNotification for Alarm Purpose. I have a custom option for repeat based on weekdays (sun, mon, tue, wed, thu, fri, sat). So many applications did this process. I tried My level best. But I can't get it to work. Please you guys help me....

Daniel
  • 23,129
  • 12
  • 109
  • 154
Ganesh
  • 819
  • 3
  • 13
  • 27

2 Answers2

25

You cannot set custom repeat intervals with UILocalNotification. This has been asked before (see below) but only limited options are provided. The repeatInterval parameter is an enum type and it limited to specific values.

You cannot multiply those enumerations and get multiples of those intervals. You cannot have more than 64 local notifications set in your app. You cannot reschedule a notification once it fires unless the user chooses to run your app when the notification fires (they may not run it).

There is a request for repeat interval multipliers posted here. You can add comments to it. I suggest filing a bug report or feature request (url?) with Apple.

Community
  • 1
  • 1
progrmr
  • 75,956
  • 16
  • 112
  • 147
  • 4
    Apple's [documentation](https://developer.apple.com/library/ios/documentation/iphone/conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW5) says **an app can schedule 128 local notifications at the same time** : _Your own apps can have no more than 128 local notifications active at any given time, any of which can be configured to repeat at a specified interval._ – nburk May 11 '14 at 11:56
  • @nburk The link in your comment no longer works. Do you happen to know if what you said is still accurate? – ndmeiri Jun 25 '15 at 08:25
  • 1
    iOS 10 has a new repeating notification option with a custom time interval option + (instancetype)triggerWithTimeInterval:(NSTimeInterval)timeInterval repeats:(BOOL)repeats; – Steve Moser Aug 24 '17 at 16:17
  • @SteveMoser do you have a link to the docs? My Google results only show me how to trigger repeated but not with a certain starting point AND repeating interval. – Matthias Max Jul 26 '19 at 14:14
2

Simply make a methods with parameters interval and weekday. And call the function every time u have to set alarm.But the Notifications for weekdays are to be settled separately.As I have called the method as given below:

            [self notificationWithItem:tempDict Date:[self SetDateForAlarmWithWeekday:2 :tempDict] andRepeatInterval:NSWeekCalendarUnit];
            [self notificationWithItem:tempDict Date:[self SetDateForAlarmWithWeekday:3 :tempDict]andRepeatInterval:NSWeekCalendarUnit];
            [self notificationWithItem:tempDict Date:[self SetDateForAlarmWithWeekday:4 :tempDict] andRepeatInterval:NSWeekCalendarUnit];
            [self notificationWithItem:tempDict Date:[self SetDateForAlarmWithWeekday:5 :tempDict] andRepeatInterval:NSWeekCalendarUnit];
            [self notificationWithItem:tempDict Date:[self SetDateForAlarmWithWeekday:6 :tempDict] andRepeatInterval:NSWeekCalendarUnit];

I passed weekday parameter for different days of week as 2 for monday,3 for tuesday and so on.

I hope it will help u...!
Prince Kumar Sharma
  • 12,591
  • 4
  • 59
  • 90