AppConfig.org
Overview¶
This tutorial will walk developers through how to send dynamic configurations to an app by utilizing the native iOS managed configuration capability as prescribed by the AppConfig.org standard. The steps in this tutorial are done with the assumption that you have gone through the steps in Getting Started tutorial.
Requirements¶
- Minimum Project Deployment Target iOS 8.0 or above
- Requires managed configuration from an MDM server to enable
- This can be implemented without an Xcode workspace, but the use of a workspace is recommended. Once you create the workspace, always open the
.xcworkspace
file instead of opening the.xcodeproj
directly.
Tutorial¶
At this point in the tutorial, we assume you have already gone through the steps listed in Getting Started tutorial to enroll a device in your AirWatch environment.
Implementation¶
- Create and open the
<project>.xcworkspace
file in Xcode. - Add your existing App to the workspace.
- Control-click in the empty area of the project navigator, choose “Add Files to “, and select the “AppConfigPasscodeFramework” Xcode project (included in the sample code file) to add it the workspace. See Apple’s help documentation for more information.
- Under the
AppConfigSettingsFramework
project in the left-hand menu, open the Products group. IfAppConfigSettingsFramework.framework
is listed in red, it has not yet been built. Click the scheme changer and choose the “AppConfigSettingsFramework” scheme, and then press command-B to build the framework. - Add
AppConfigSettingsFramework
to “Embedded Binaries” in your app target’s general settings; this will cause it to also be added to “Linked Frameworks and Libraries” immediately below. - Edit the application’s AppDelegate:
-
Swift:
- Import the Framework:
import AppConfigSettingsFramework
- Declare that AppDelegate implements the
ManagedAppConfigSettingsDelegate
protocol:class AppDelegate: UIResponder, UIApplicationDelegate, ManagedAppConfigSettingsDelegate
- Implement the delegate protocol method:
func settingsDidChange(changes: Dictionary<String, AnyObject>) { print("Received \(changes)") }
- Within
application(application: UIApplication, didFinishLaunchingWithOptions
set the delegate and callstart()
ManagedAppConfigSettings.clientInstance().delegate = self ManagedAppConfigSettings.clientInstance().start()
- Import the Framework:
-
Objective-C:
- Import the Framework in
AppDelegate.h
:@import AppConfigSettingsFramework;
- Declare that AppDelegate implements the
ManagedAppConfigSettingsDelegate
protocol@interface AppDelegate : UIResponder <UIApplicationDelegate, ManagedAppConfigSettingsDelegate>
- Implement the delegate protocol method in
AppDelegate.m
:
- (void) settingsDidChange:(NSDictionary<NSString *, id> *) changes { NSLog(@"Received changes %@", changes); }
- Import the Framework in
-
Within
application:didFinishLaunchingWithOptions:
set the delegate and callstart()
[ManagedAppConfigSettings clientInstance].delegate = self; [[ManagedAppConfigSettings clientInstance] start];
Deploy your app¶
After you have written the code to receive and read the iOS managed configurations, you’ll need to deploy and managed the app using AirWatch.
- Go back to your AirWatch admin console.
- Edit the app you uploaded in the Getting Started tutorial.
- Click on Save & Assign and then edit the assignment you had previously created.
- Expand Advanced and then Application Configuration
- Add your configuration keys and values that you want to send to your app.
- Click on add at the bottom of the page when you’re done to add the assignment
- Now back on your enrolled mobile device, install your app from the AirWatch App Catalog and run the app to read the assigned configurations you just set.