ios - 如何在 iOS 中监听通知关闭事件?

标签 ios ios8 apple-push-notifications uilocalnotification

我正在监听为我的本地通知按下的操作,但是有没有办法确定用户何时关闭通知?

以下是我如何在我的 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/

相关文章:

ios - 当我不得不查询Apple的反馈服务时

ios - 如何知道用户是否更改了选项卡?

ios - 提醒用户该应用仍在使用位置更新 (GPS)

objective-c - 检测 iOS 8 自定义键盘中的键盘类型更改

apple-push-notifications - apns-expiration 字段的默认值是多少?

ios - 从 iOS 上传的 SoundCloud 下载文件名不正确

ios - 再次发送通知

ios - iOS8 中未调用 UIViewController 设备旋转委托(delegate)方法

ios - 点击推送通知时打开浏览器

ios - APNS 紧急通知的适用性和可靠性