Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using MDM To Configure An Enterprise App Via NSUserDefaults

Tags:

I'm using Profile Manager in OS X Server 3.0.1 on 10.9 to push my enterprise app to a managed device running iOS7. This is working well, and I am also able to push device configuration settings.

My roadblock is how to take the information offered in Apple's example project, ManagedAppConfig, and apply it to an app distributed by Profile Manager.

ManagedAppConfig provides a simple plist which is supposed to be used to put data into an app's NSUserDefaults, which is then used for app configuration; but, there is no direction given for how to use MDM to get this data dictionary into the NSUserDefaults.

I am obviously missing a piece of information for how to send a plist of data to a managed app's NSUSerDefaults, but so far my searching has been fruitless. Is it possible to to this with Profile Manager? Is there another way with OS X Server that I haven't yet found?

Here's a quote from Apple's doc on ManagedAppConfig:

"ManagedAppConfig" demonstrates how to implement managed app configuration and feedback support in an iOS application. This functionality allows a Mobile Device Management (MDM) server to push down a dictionary into the managed app's NSUserDefaults for the purposes of remotely configuring settings.

Here's the example plist with the two pieces of data which are somehow placed in the app's NSUserDefaults:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict>     <key>serverURL</key>     <string>http://developer.apple.com/</string>     <key>disableCloudDocumentSync</key>     <true/> </dict> </plist> 

The docs for NSUserDefaults even mention configuration via MDM, but no specifics are given.

If your application supports managed environments, you can use an NSUserDefaults object to determine which preferences are managed by an administrator for the benefit of the user. Managed environments correspond to computer labs or classrooms where an administrator or teacher may want to configure the systems in a particular way. In these situations, the teacher can establish a set of default preferences and force those preferences on users. If a preference is managed in this manner, applications should prevent users from editing that preference by disabling any appropriate controls.

My afternoon has been spent pursuing this elusive piece of info without success, so I ask the assistance of the SO community. Can anyone point me to the info I need to use MDM to stick a dictionary of data into NSUserDefaults?

Many Thanks.

like image 824
xi golom Avatar asked Dec 23 '13 22:12

xi golom


2 Answers

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.

like image 125
Tomas McGuinness Avatar answered Oct 04 '22 10:10

Tomas McGuinness


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.

like image 25
Ohad Cohen Avatar answered Oct 04 '22 10:10

Ohad Cohen