0

Has anyone been successful at scheduling a repeating hourly local notification with UNUserNotificationCenter without creating multiple request?

I need to be able to schedule hourly notifications to go off at a specific minute from which the first notification is set to go off. I am able to do this using the old UILocalNotification framework but I want to be able to take advantage of notification extensions, titles, subtitles etc that come along with the new notifications framework.

If it's not possible to schedule a single request that repeats hourly at a specific time, has anyone found a way to achieve this using multiple requests? And doing so without requiring the user to action against the first notification?

My other concern with scheduling multiple requests is that my app allows a user to create multiple reminders and I don't want to limit the user due to the 64 notification cap

Edit: My current use case is, it's 6:30am and I want to schedule a notification to trigger at 10:43 pm and from that point repeat hourly at 43 minutes past every hour. This is currently achievable with UILocalNotification using repeatInterval and setting the units to hour, so it will fire at that time and every hour after

bevbomb
  • 689
  • 2
  • 12
  • 26
  • For notifications, I'm using OneSignal, I don't know if it's possible – Arthur Guiot Apr 02 '17 at 03:42
  • It's possible, but it wouldn't be a local and at this point it might be the path I take, a lot of apps like todo-ist use push for reminders etc rather then local. It just means I'll have to write a cronjob to process the repeating – bevbomb Apr 02 '17 at 03:51
  • No way to do this using Apple's new API, unfortunately. – faircloud Apr 02 '17 at 04:14

1 Answers1

0

In sentence

to schedule a notification to trigger at 10:43 pm and from that point repeat hourly at 43 minutes past every hour

only "from that point" is impossible.

You can create UNNotificationRequest with UNCalendarNotificationTrigger with DateComponents(minute: 43, second: 00) which will start firing at XX:43:00 every hour since request will be added to UNUserNotificationCenter.

The only problem left is to add it in period from 09:44pm to 10:42pm so it will not start firing too early. I don't see beautiful way to accomplish that, but if push notification is good enough for you - it can be a trigger that will add request to notification center.

abjurato
  • 1,439
  • 11
  • 17