简体   繁体   中英

Cocoa / NSUserNotificationCenter get all NSUserNotification notifications

How can I be notified whenever any application delivers or activates an NSUserNotification ?

  • Neither could I determine anything that is sent via NSDistributedNotificationCenter ,
  • nor could I find a mask like NSUserNotificationDeliveredMask [dummy name] I could register a global [NSEvent addGlobalMonitorForEventsMatchingMask] for,
  • nor does there seem to be a suitable observer for the default user notification center object.

The [NSUserNotificationCenter defaultCenter] and its delegate only notify me when my own app delivers a notification.

This answer should address how to receive available notifications from NSDistributedNotificationCenter . There doesn't seem to be any way to get all NSUsernotifications as far as I know, though.

It is not possible. You can only listen to NSDistributedNotificationCenter for "global" notifications. The app developer has to broadcast to NSDistributedNotificationCenter for you to hook into it.

You can't hijack other applications Notifications. Most apps and all apps distributed through App Store is sandboxed. The very nature of this limits your ability to hook into them!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM