Distributed notification center not notifying distributedly

In a deamon, I register using:

[[NSDistributedNotificationCenter defaultCenter] addObserver:loader
    selector:@selector(getNotifications:)
    name:kProxyStartNotification
    object:@"MyProxy"];

In the transparent proxy provider, I post using:

static let dnc = DistributedNotificationCenter.default()
// later
Self.dnc.postNotificationName(.proxyStart,
                                      object:"MyProxy",
                                      deliverImmediately:true)

(I also tried putting the same observer code in the containing app, just to be sure.)

(Also, btw: the automatic conversion of kProxyStartNotification to Notification.Name.proxyStart is really sweet.)

I'm not getting the notification in other processes. I tried putting an observer in the extension, and sure enough that did get the notification, so it is being generated. Just... not leaving my process.

I tried checking for sandbox violations, using Quinn's instructions, but see nothing.

I also tried

[[NSDistributedNotificationCenter defaultCenter] addObserver:loader
    selector:@selector(getNotifications:)
    name:nil
    object:@"MyProxy"];

(and the same in Swift, for the network extension), and -- as can be guessed by my still asking this question -- no luck.

Answered by DTS Engineer in 708319022

When working at this layer I recommend that you use Darwin notifications, that is, <notify.h> as documented in the notify man page. Foundation’s distributed notifications introduce all sorts of complexity related to both login sessions and App Sandbox.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

When working at this layer I recommend that you use Darwin notifications, that is, <notify.h> as documented in the notify man page. Foundation’s distributed notifications introduce all sorts of complexity related to both login sessions and App Sandbox.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is there a sample or set of documentation for using that in Swift? (I'm still very, ahem, fuzzy on using-C-from-Swift.)

I wrote a really stupid ObjC class to post notifications. (And then ran into this wonderful fact: I couldn't use the method names I wanted, because Swift decided they'd been renamed due to NotificationCenter. Is this a bug?)

Then I added some C code to the daemon and voila, NOTIFICATIONS.

As always thank you Quinn!

Distributed notification center not notifying distributedly
 
 
Q