Detect Other Button click (NSUserNotification)

白昼怎懂夜的黑 提交于 2019-12-01 08:33:20

After... uhm.... "checking" out the mail app's code... I found a suspicious function in their notification controller class...

- (void)userNotificationCenter:(NSUserNotificationCenter *)center didDismissAlert:(NSUserNotification *)alert

I have no idea why apple don't want to add this function to the NSUserNotificationDelegate... but I tested this out in my app and it works!!!

Swift >= 4 version:

@objc
func userNotificationCenter(_ center: NSUserNotificationCenter, didDismissAlert notification: NSUserNotification)

Make sure you add the @objc annotation, otherwise the objective-C runtime won't be able to see your delegate method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!