We are using Manged App Configurations to dynamically push values to our app. We eventually want these values to reach our Network Extension process (specifically PacketTunnelProvider). However, there's some problems here:
MDM providers only allow us to send configurations to app, not the extension. There's not really a way for us to reach the app configuration from the extension (even if the extension and app are in the same app group), because the app config is placed in [NSUserDefaults standardUserDefaults]
A workaround would then be for the app to monitor for any AppConfig changes using NSUserDefaultsDidChangeNotification
, and then write the app config settings to a shared NSUserDefaults instance. But when the app is in the background (most of the time for network extension apps), those notifications don't fire. I've attempted to use KVO to notify on any changes such as below:
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:@"com.apple.configuration.managed" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:NULL];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
NSLog(@"%@", [change description]);
}
But I am not seeing any KVO notifications here, even when NSUserDefaultsDidChangeNotification
fires.
This would be a workaround, but if the app is not running (due to connect-on-demand) or some other reason, this still would not work.
Is there any possible workarounds or things that we can do here? Any help would be appreciated. Thanks