我正在开发一个快速的OS X应用程序,但在理解userNoticiation / didActivateNotification结构时遇到了麻烦。我已经查看了文档并进行了搜索,但仍然无法解决。对于以下代码的任何指导将不胜感激:
func notify(message: String, callBack: String) {
println(message)
println(callBack)
var notification:NSUserNotification = NSUserNotification()
notification.title = "New Phone Call"
notification.informativeText = message
notification.actionButtonTitle = "Lookup"
notification.hasActionButton = true
var center:NSUserNotificationCenter = NSUserNotificationCenter.defaultUserNotificationCenter()
center.delegate = self
center.scheduleNotification(notification)
}
func notify (center: NSUserNotificationCenter, didActivateNotification notification: NSUserNotification){
center.delegate = self
println("clicked") //this does not print
}
通知将完全按照我的意愿显示。单击我已定义的“查找”按钮,将使应用程序在首次单击时进入前台,但是我希望处理该操作的代码不会触发。
提前致谢。
将您的第二个“功能通知”声明更改为“可选的func userNotificationCenter”
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句