How to make a local notification for daily/hourly to Swift?

Good time of day. New to Swift, so have not found the answer to the question in Google. Do not judge strictly.
Made an app with local notifications. I would want that every day the app gave a notification with a NEW phrase.
How to make the notifications by the date? That is what 18/02/20 at 18:54 application issued the sentence. Next 19:02:20 at 18:54 given the following sentence.
How to make this type of notification, and how to "push" a simpler way?
April 7th 20 at 15:17
2 answers
April 7th 20 at 15:19
let content = UNMutableNotificationContent()
content.sound = .default
content.title = "Title"
content.body = "Message"

var dateComponents = DateComponents()
dateComponents.hour = 9
dateComponents.minute = 0
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true)
let request = UNNotificationRequest(identifier: UNNotificationRequest.weeklyAlKahID, content: content, trigger: trigger)

UNUserNotificationCenter.current().add(request) { error in
 guard error == nil else {
 print(error ?? "Error with donate")
return
}
}


In this example, every 9 a.m. will be delivered the notice. Please note, the trigger should repeat. Do not forget to request permission to push.

PS This is a trivial question. You must be a novice developer. The community is not accepted with any problem to turn on the toaster, the first 5 links on Google to the question local notification in swift are also good answers.
@caterina_Huel26 , thank you! Here I can add more .date, right? What would the notification came out at the right date.
And how to make it so that every day was a new text (for example, I will register the code for the week ahead). At what point to duplicate code for writing the new dates and text? I want to implement functionality: each day will eject the new phrase. Doing this entirely for myself. - jay_Padbe commented on April 7th 20 at 15:22
@rosie56, then in the cycle need to set the text and time, without repeat. - ella.Schulist commented on April 7th 20 at 15:25
@caterina_Huel26, okay, thank you, and then, under each sentence, I re-prescribe:

let content = UNMutableNotificationContent()
content.sound = .default
content.title = "Title"
content.body = "Message"

var dateComponents = DateComponents()
dateComponents.hour = 9
dateComponents.minute = 0
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false)
let request = UNNotificationRequest(identifier: UNNotificationRequest.weeklyAlKahID, content: content, trigger: trigger)

Right? - jay_Padbe commented on April 7th 20 at 15:28
@rosie56you have left us a little disappointed. Not established date of notification.
This number will send the Header and the Message at 9 am every day. - ella.Schulist commented on April 7th 20 at 15:31
@caterina_Huel26, ripit removed, just can't find in Google how to put a date and what format to do it?
dateComponents.date = 02.03.2020? For example. I do not think that is correct. - jay_Padbe commented on April 7th 20 at 15:34
@rosie56have dateComponents you can set the day, month and year. - ella.Schulist commented on April 7th 20 at 15:37
April 7th 20 at 15:21
If you have already made such an application, you know what the trigger is.
Use for your trigger notifications UNCalendarNotificationTrigger, which specify only the hour and minute (and second) of notification. But do not specify a day, month, etc.
Here's an example notice with this trigger will be triggered at 8:30
var date = DateComponents()
date.hour = 8
date.minute = 30 
let trigger = UNCalendarNotificationTrigger(dateMatching: date, repeats: true)
repeats is, why raise again. - ella.Schulist commented on April 7th 20 at 15:24
@caterina_Huel26, sorry, Yes. what I parayil ))) - Madyson.Stiedemann commented on April 7th 20 at 15:27
@dean_Grant, but I get repeats is not necessary, as the phrase I will appear different, and each notification is necessary only once. Necessary as it is to think so, that would make a huge list of phrases and random method to display them in the text of the notification. - jay_Padbe commented on April 7th 20 at 15:30

Find more questions by tags NotificationsSwift