I'm just making my first app and I'm facing probably the biggest problem in it.I tried to make repeating local notifications with for loop each having different category but for some reason it doesn't work. I actually get all of the notifications but when I pull down on notification to see the actions I don't see any actions.Have you ever faced this kind of problem and if you do how did you manage to solve it?The notifications I am trying to make are repeating local notifications scheduled for today.
Here is my code:
for index in 0..<workingDays[3].subjects!.count {
howManyLeft -= 1
var seperated = workingDays[3].subjects![index].endsAt!.components(separatedBy: ":")
var dateComponents = DateComponents()
dateComponents.hour = Int(seperated[0])
dateComponents.minute = Int(seperated[1])
dateComponents.weekday = 5
// make category
let actionBaby = UNNotificationAction(identifier: "oneaction\(index)", title: "something\(index)", options: .foreground)
let category = UNNotificationCategory(identifier: "\(index).5", actions: [actionBaby], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: "idk", options: [])
UNUserNotificationCenter.current().setNotificationCategories([category])
// If contition is true make notification
if index + 1 >= 0 && index + 1 < workingDays[3].subjects!.count {
let notification = UNMutableNotificationContent()
notification.categoryIdentifier = "\(index).5"
notification.title = "someRandom\(index)"
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true)
let request = UNNotificationRequest(identifier: "\(index)5",
content: notification,
trigger: trigger)
UNUserNotificationCenter.current().add(request)
}
}