Je suis listneing aux actions pressées pour mes notifications locales, mais est-il un moyen de déterminer quand l'user rejette une notification?
Voici comment j'écoute mes actions dans mon AppDelegate, mais le rejet ne triggers pas ceci:
func application(application: UIApplication, handleActionWithIdentifier identifier: Ssortingng?, forLocalNotification notification: UILocalNotification, completionHandler: () -> Void) { var actionName: Ssortingng? = nil if let identifier = identifier { switch identifier { case "snoozeAction": actionName = "snoozeActionTapped" break default: break } if let name = actionName { NSNotificationCenter.defaultCenter().postNotificationName(name, object: nil) } } completionHandler() }
Le rejet d'une notification ne réveille pas votre application, il n'y a donc aucun moyen de capturer cela.
Vous devriez essayer ceci:
func application(application: UIApplication!, handleActionWithIdentifier identifier:Ssortingng!, forLocalNotification notification:UILocalNotification!, completionHandler: (() -> Void)!){ if (identifier == "FIRST_ACTION"){ NSNotificationCenter.defaultCenter().postNotificationName("actionOnePressed", object: nil) }else if (identifier == "SECOND_ACTION"){ NSNotificationCenter.defaultCenter().postNotificationName("actionTwoPressed", object: nil) } completionHandler() }