Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Notify web extension native process of user default changes

My Mac app and its Safari web extension share an app group, and I want to notify the web extension native process when the app makes a change to the app group NSUserDefaults, but I can't find a good way to do this.

According to the documentation, "You can use key-value observing to register observers for specific keys of interest in order to be notified of all updates, regardless of whether changes are made within or outside the current process." In my testing, however, this doesn't work in the web extension process. I'm using NSUserDefaults addObserver forKeyPath, but observeValueForKeyPath never gets called.

I've also tried NSDistributedNotificationCenter, but the web extension process doesn't receive the notifications sent by the main app.

Are either of these supposed to work? If not, are there any alternatives?

Notify web extension native process of user default changes
 
 
Q