Using MDM To Configure An Enterprise App Via NSUserDefaults

扶醉桌前 提交于 2019-11-27 12:07:34

I've written a small blog post on how you would go about testing the ManagedAppConfig from Apple.

http://tomasmcguinness.com/2014/03/07/exploring-apples-managedappconfig-demo/

Disclosure: This post describes using www.testmdmapp.com, which I've written.

Managed app configuration changes that are pushed down from an MDM server appear in NSUSerDefaults so you can add an observer to be alerted of any changes to NSUserDefaults. The Managed app configuration dictionary pushed down from the MDM server is stored in the key named: com.apple.configuration.managed

Your application can also send a dictionary containing the feedback to the MDM server. The dictionary that is sent back to the MDM server as feedback must be stored in this key com.apple.feedback.managed

In order to test all of this you would need a device that is managed by an MDM server and the application must be installed by the MDM server that supports ApplicationConfiguration setting and ManagedApplicationFeedback commands.

The sample application's readme.txt file recommends seeing the WWDC 2013 Session 301 "Extending Your Apps for Enterprise and Education Use" for a demo of this application.

to read the config (swift 3):

if let managedConf = UserDefaults.standard.object(forKey: "com.apple.configuration.managed") as? [String:Any?] {
    if let serverURL = managedConf["serverURL"] as? String{
        return serverURL
    }
}
if let serverURL = Bundle.main.object(forInfoDictionaryKey: "serverURL") as? String {
    return serverURL
}
return  "https://apple.com/"

as you can see - the app needs to manually enable reading from MDM bundle configuration.

P,S: only managed apps can get those configs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!