AirWatch Managed AppConfig Sample - iOS

iOS provides native APIs to fetch managed AppConfig to devices that are enrolled into an EMM provider, such as AirWatch. These values are sent to devices using the MDM protocol. It is crucial that the app in question is configured correctly in the AirWatch Console so that it can leverage managed AppConfig. The prerequisites for leveraging managed AppConfig on the iOS platform are:

  • An iOS application written as per Apple's managed AppConfig guidelines
  • AirWatch enrolled devices that are assigned to the app

 

Develop an app that supports Managed AppConfig on iOS

Fetch managed AppConfig using the following code:

func fetchAppConfiguration() {
     if let managedConfigDict = UserDefaults.standard.dictionary(forKey: "com.apple.configuration.managed"){
          if let keyValue = managedConfigDict["keyName"]{
               print("KEY : keyname \nVALUE : \(keyValue) ")
          }
     }else{
          print("Error fetching app config values. Please make sure your device is enrolled with AirWatch ")
     }
}

 

Register your app to listen for managed AppConfig changes:

Developers can register their app to listen for userdefault changes. This action allows the app to dynamically pick up the latest managed AppConfig sent by AirWatch.

func registerForAppConfigNotification() {
     NotificationCenter.default.addObserver(self, selector: #selector(ViewController.fetchAppConfiguration), 
          name: UserDefaults.didChangeNotification, object: nil)
}

 

See the sample app:

Developers can locate the implementation of managed AppConfig in our AppConfig sample app. Find it under the ViewController swift class.

 

Publish and update Managed AppConfig for your app in AirWatch

Manually: An AirWatch administrator can push the managed AppConfig for their enterprise apps using the following steps.

  1. Under the Internal App Detail view select Assign.
  2. Select the Smart Group and choose Edit Assignment.
  3. Scroll down and enable App Configuration.
  4. Enter the key-value pairs required for apps. The keys must match the key-value pairs programmed into the application by the developer.
  5. Save and Publish the changes.

 

Uploading XML: An AirWatch administrator can push the managed AppConfig by uploading an XML file containing the key-value pairs.

  1. Under the Internal App Detail view select Assign.
  2. Select the Smart Group and choose Edit Assignment.
  3. Scroll down and enable App Configuration.
  4. Select Upload XML.
  5. Save and Publish the changes.

Note: This option was introduced in AirWatch 9.1. The XML schema should look like the following snippet. Replace the bundle ID with the bundle ID of your application and change the key-value pairs as appropriate.

<managedAppConfiguration>
     <version>1</version>
     <bundleId>com.vmware.gss.AirWatchAppConfigSample</bundleId>
     <dict>
          <string keyName="awservername">
               <defaultValue>
                    <value>server.awmdm.com</value>
               </defaultValue>
          </string>
          <integer keyName="counter">
               <defaultValue>
                    <value>250</value>
               </defaultValue>
          </integer>
     </dict>
</managedAppConfiguration>

 

An AirWatch administrator can update the managed AppConfig for their enterprise apps using the following steps:

  1. Update the values for the managed AppConfig keys by navigating to Edit Application > Assignment > Application Configuration.
  2. Select Save and Publish.
  3. Navigate to App Details and select More > Send Application Configuration.

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.