How to repeat local notifications on specific days of the week (iOS Swift 3)

I am creating my first app that lets the user set alerts for themselves and then the app would send the user a local notification on the set time. The thing that I’m having trouble with now is being able to fire the local notification on specific days of the week (for example every Mondays and Tuesdays only). All the tutorials/questions that I have come across so far (like this one) have only been about scheduling the notification everyday/everyweek. The desired result that I’m trying to achieve is sort of like the iPhone’s built in alarm system, where you can set an alarm to fire only on certain days of the week.

If I can’t just set the notification.repeatInterval field, is there a way I can do what I’m trying to do? Could I possibly execute a little code at midnight that schedules the correct notifications for that day? If so, how could I do that?

  • Realm - Can't create object with existing primary key value
  • How to create a TIFF on the iPad
  • xcode showing warnings as errors
  • Objective C: UIDatePicker UIControlEventValueChanged only fired on second selection
  • How to write custom metadata to PNG images in iOS
  • How to access ViewController component from PageViewController
  • Thanks in advance!

    Solutions Collect From Internet About “How to repeat local notifications on specific days of the week (iOS Swift 3)”

    The thing that I’m having trouble with now is being able to fire the local notification on specific days of the week

    In iOS 10, a UNCalendarNotificationTrigger is formed using DateComponents. This means you can specify as much or as little of the date-time in question as you wish. Thus, if you specify a specific weekday and a time (hour and minutes), and nothing else, you’ll repeat at that time on that day of the week.

    If you also need to repeat on a different day of the week, just make another notification.