iOS本地通知缺less动作button

我只是做我的第一个应用程序,我可能面临可能是最大的问题。我试图使重复本地通知与循环各有不同的类别,但由于某种原因,它不工作。 我实际上得到所有的通知,但当我拉下通知看行动,我没有看到任何行动。你曾经遇到过这样的问题,如果你做了你是如何设法解决它?我的通知试图制定今天重复的本地通知。

这是我的代码:

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) } } 

Interesting Posts