如何在iOS中收听通知被驳回的事件? [英] How to listen for notification dismissed event in iOS?
本文介绍了如何在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中收听通知被驳回的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文