J'utilise le code ci-dessous pour créer une notification, mais d'une manière ou d'une autre, il ne se déclenche pas. Je veux juste que ça se déclenche quand j'ouvre un certain contrôleur de vue, mais rien ne se déclenche jusqu'ici. Quel est le problème avec mon code?Essayer de déclencher UILocalNotification ne fonctionne pas
func notify() {
let notification = UILocalNotification()
notification.fireDate = Date()
notification.repeatInterval = .minute
notification.alertBody = "The alert body"
notification.alertAction = "enter text here"
UIApplication.shared.scheduleLocalNotification(notification)
}
J'ai aussi cette ligne dans le délégué de l'application:
application.registerUserNotificationSettings(UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil))
C'était tout! Quand j'ai changé la date à un peu plus tard, cela a fonctionné à nouveau et m'a donné des notifications. – Misha