本文介绍了如何在 iOS 中监听通知解除事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在监听为我的本地通知按下的操作,但有没有办法确定用户何时取消通知?
I am listneing to actions pressed for my local notifications, but is there a way to determine when the user dismisses a notification?
以下是我在 AppDelegate 中监听我的操作的方式,但关闭不会触发:
Here is how I'm listening to my actions in my AppDelegate, but the dismiss doesn't fire this:
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()
}
推荐答案
关闭通知不会唤醒您的应用程序,因此无法捕获此信息.
Dismissing a notification does not wake your application up so there is no way to capture this.
这篇关于如何在 iOS 中监听通知解除事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!