How to access UWP application settings set by MDM?

2019-07-17 06:19发布

问题:

I am using EnterpriseModernAppManagement CSP to install and set settings for some UWP app as defined here:

https://msdn.microsoft.com/en-us/library/windows/hardware/dn904956(v=vs.85).aspx

.../PackageFamilyName/AppSettingPolicy/SettingValue (only for ./User/Vendor/MSFT) Added in Windows 10, version 1511. The SettingValue and data represent a key value pair to be configured for the app.

UWP app installs correctly and settings setup (via AppSettingPolicy) execute successfully.

But how do I now access those custom settings inside the app itself with c#?

Both Windows.Storage.ApplicationData.Current.LocalSetting.Values and Windows.Storage.ApplicationData.Current.RoamingSettings.Values key/value pairs seem empty and unaffected by MDM changes.

Is there any way to send arbitrary settings/configuration to a custom UWP application via MDM?

回答1:

Apparently, new container is created in app's local settings after AppSettingPolicy key value pairs are pushed via EnterpriseModernAppManagement CSP.

Values can be accessed via:

ApplicationData.Current.LocalSettings.Containers["Managed.App.Settings"].Values

It would be nice if this was documented somewhere! :)