26

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.

xi golom
  • 351
  • 1
  • 3
  • 9
  • 1
    Were you able to get this to work? If the guidelines in the ManagedAppConfig project are followed will this work with most MDMs? – Heinrich Oct 26 '15 at 02:05
  • Any one can help with airwatch mdm solution. I am trying to configure mdm in Airwatch to send url, portnumber. – Durgaprasad Nov 16 '15 at 10:24
  • Did you have any success with this? I've used AirWatch to push configuration to the user defaults visible with the com.apple.configuration.managed key. However, we can't get this to work with M$ Intune, which I suspect requires a super secret xml formatted file to be uploaded. – user3335999 Oct 23 '20 at 18:17

3 Answers3

18

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.

Tomas McGuinness
  • 7,651
  • 3
  • 28
  • 40
  • I am getting message app is not managed when I try to configure app using your blogpost.Can you please suggest me something? – Imran Jul 21 '14 at 06:25
  • 1
    Only apps installed via an MDM can be configured. In your case, you must first install your app using TestMDM and then perform the configuration step. – Tomas McGuinness Jul 21 '14 at 13:11
  • @tomasmcguinness Thanks for your answer. We faced some strange problem with managed app configuration in iOS 8: http://stackoverflow.com/questions/29231487/ios-8-mdm-managed-app-configuration-doesnt-work. Do you know anything about it? – alexey Mar 24 '15 at 11:41
  • Tomas, do you know if it is possible to use managed app configuration with apps distributed via the Volume Purchase Program (B2B Store). Is this something Apple will allow. If so how do they do this during the app approval process – rideintothesun Apr 15 '15 at 15:18
  • I believe so. B2B works in the way as standard VPP, with the exception that access is limited. When it comes to managed app configuration, there is nothing to do in the app approval process except explain how to test it (if required). Drop me an email if you want to discuss in more detail. – Tomas McGuinness Apr 16 '15 at 07:23
  • Nice work but what is the format of the plist configuration used to make available the dictionary accessible by the key com.apple.configuration.managed? – user3335999 Oct 23 '20 at 18:19
  • I believe any PList document can be used, once it's correctly formatted. There are lots of examples out there; here is one - https://gist.github.com/mallibone/a56cc79479d0944af22c470477d85272 – Tomas McGuinness Oct 28 '20 at 06:58
15

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.

Ohad Cohen
  • 5,756
  • 3
  • 39
  • 36
13

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.

Sharjeel Aziz
  • 8,495
  • 5
  • 38
  • 37
  • 5
    Can any iOS app with NSUserDefaults be configured by an MDM or do you need to take extra steps to allow this? I wrote an app that I will give to a customer and they want to push app preferences to the users through MobileIron. – Heinrich Oct 05 '15 at 04:09
  • Do I need to specifically have a ManagedAppConfig.plist bundled with my app as well? The sample application shows one in the project, but the documentation says this file is used for sending only via MDM. – Nick N Mar 15 '16 at 21:58
  • 1
    Can I assume that if "com.apple.configuration.managed" key is available on NSUSerDefaults the app was installed using MDM? – Jona Mar 31 '21 at 14:23