我正在监听为我的本地通知按下的操作,但是有没有办法确定用户何时关闭通知?
以下是我如何在我的 AppDelegate 中监听我的操作,但解雇并没有触发:
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forLocalNotification notification: UILocalNotification, completionHandler: () -> Void) {
var actionName: String? = 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()
}
最佳答案
关闭通知不会唤醒您的应用程序,因此无法捕获它。
关于ios - 如何在 iOS 中监听通知关闭事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30153519/