0

Im building a Calendar app, where you can schedule events, and you get Notified by UserNotification.

The Problem is that i recently read that you can only have 64 scheduled events. But what if the user has more than 64 events? I know repeated notifications are counted as one. Does this limit count for all notification types (Timer,Calendar,Loacation)?

How would u solve this issue? Since i don't use a server, i cant make push/remote notifications.

Looking forward to ur answers!

Thanks in advance!

Elliot Czigány
  • 188
  • 1
  • 14

1 Answers1

1

After the 64th event, you can try to save the ones after that and schedule them once the number of current scheduled event is less than 64. You should take into account the event's schedule time to avoid missing event with sooner start date.

EDIT

Since your app allows user to schedule future events, it makes sense to use CoreData to persist data. For each event they created, you can create an entity with following attributes:

  • event name
  • event start date
  • isScheduled boolean

This should be fairly simple. After that, whenever the app starts, you can fetch the events and schedule the ones with closest start date. This way, you don't have to schedule an event too far ahead.

If you want to check the number of scheduled events, you can do

UIApplicaiton.shared.scheduledLocalNotifications?.count

This method works but it is deprecated so you might want to use

UNUserNotificationCenter.getPendingNotificationRequests
Linh Ta
  • 593
  • 6
  • 11
  • How should i do this? can you maybe give a code example? I do not get the saving part. – Elliot Czigány Jul 10 '18 at 10:54
  • I have updated my answer. If you have never used CoreData before, I can help you with a short tutorial. @ElliotCzigány – Linh Ta Jul 10 '18 at 16:42
  • Wow thank you! Actually i never used CoreData because i heard about Realm, and imo its is easier to use. So, if i get everything right at the start of the app, lets say at didFinishLaunchingWithOptions i check the number of notifications, if its below 64 then i fill up the empty space from the begining. The only thing i dont know is how to find out when i launch my app the next time, from where to continue. Or should i just delete them all at start and add 64 every launch? – Elliot Czigány Jul 10 '18 at 17:56