Bri*_*lph 7 macos nsusernotification nsusernotificationcenter swift
我正在研究一个快速的os x应用程序,我无法理解userNoticiation/didActivateNotification结构.我查看了文档并搜索了SO但仍然卡住了.我们非常感谢您对以下代码的任何指导:
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
}
Run Code Online (Sandbox Code Playgroud)
通知显示完全符合我的要求.单击我定义的"查找"按钮会在第一次单击时将我的应用程序带到前台,但是我希望处理该操作的代码不会触发.
提前致谢.
| 归档时间: |
|
| 查看次数: |
1696 次 |
| 最近记录: |