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.
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"