[iOS] get MDM settings from system dictionary in swift

Posted in :

透過 iOS MDM 派送參數給 Device,範例程式如下:

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)
}

詳全文:

https://support.air-watch.com/articles/115006426588-AirWatch-Managed-AppConfig-Sample-iOS

 

相關文章:

Configure Managed Settings for iOS Devices
https://my.air-watch.com/help/9.2/en/Content/Platform_Guides/iOS/T/ManagingiOSManagedSttngs.htm

發佈留言

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