MDM推送設定值到 iOS device

透過 mdm 派送 settings 到 iOS app 的方法是透過 ApplicationConfiguration 指令來派送,ApplicationConfiguration指令要能正確執行的前提是:

  1. 要被派送settings 的 App Identifier 要存在
  2. 被派送 settings 的 app 必需是被管控制。
    (透過 InstallApplication command 去安裝)

出錯之後,MDM 告訴我們的Error Message:

 <string>App「app id」不受管理。</string>
 <string>The app “app id” is not managed.</string>

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:

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

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: "") 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  ""

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

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


Using MDM To Configure An Enterprise App Via NSUserDefaults



// The Managed app configuration dictionary pushed down from an MDM server are stored in this key.
static NSString * const kConfigurationKey = @"";

// This sample application allows for a server url and cloud document switch to be configured via MDM
// Application developers should document feedback dictionary keys, including data types and valid value ranges.
static NSString * const kConfigurationServerURLKey = @"serverURL";
static NSString * const kConfigurationDisableCloudDocumentSyncKey = @"disableCloudDocumentSync";

// The dictionary that is sent back to the MDM server as feedback must be stored in this key.
static NSString * const kFeedbackKey = @"";

// This sample application tracks a success and failure count for the loading of a UIWebView.
// Application developers should document feedback dictionary keys including data types to expect for feedback queries
static NSString * const kFeedbackSuccessCountKey = @"successCount";
static NSString * const kFeedbackFailureCountKey = @"failureCount";

- (void)readDefaultsValues {
    NSDictionary *serverConfig = [[NSUserDefaults standardUserDefaults] dictionaryForKey:kConfigurationKey];
    NSString *serverURLString = serverConfig[kConfigurationServerURLKey];
    // Data coming from MDM server should be validated before use.
    // If validation fails, be sure to set a sensible default value as a fallback, even if it is nil.
    if (serverURLString && [serverURLString isKindOfClass:[NSString class]]) {
        self.serverURLUILabel.text = serverURLString;
    } else {
        self.serverURLUILabel.text = @"";
    NSNumber *disableCloudDocumentSync = serverConfig[kConfigurationDisableCloudDocumentSyncKey];

    if (disableCloudDocumentSync && [disableCloudDocumentSync isKindOfClass:[NSNumber class]]) {
        self.cloudDocumentSyncEnabledSwitch.on = ![disableCloudDocumentSync boolValue];
    } else {
        self.cloudDocumentSyncEnabledSwitch.on = YES;
    // Fetch the success and failure count values from NSUserDefaults to display.
    // Data validation for feedback values is a good idea, in case the application wrote out an unexpected value.
    NSDictionary *feedback = [[NSUserDefaults standardUserDefaults] dictionaryForKey:kFeedbackKey];
    NSNumber *successCount = feedback[kFeedbackSuccessCountKey];
    if (successCount && [successCount isKindOfClass:[NSNumber class]]) {
        self.successCount = [successCount unsignedIntegerValue];
    } else {
        self.successCount = 0;
    self.successUILabel.text = [NSString stringWithFormat:@"%lu", (unsigned long)self.successCount];
    NSNumber *failureCount = feedback[kFeedbackFailureCountKey];
    if (failureCount && [failureCount isKindOfClass:[NSNumber class]]) {
        self.failureCount = [failureCount unsignedIntegerValue];
    } else {
        self.failureCount = 0;
    self.failureUILabel.text = [NSString stringWithFormat:@"%lu", (unsigned long)self.failureCount];



Sample iOS 行動裝置管理伺服器(MDM server)

[iOS] install / uninstall app on device through MDM server?


發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *