1. 程式人生 > >[iOS] get MDM settings from system dictionary in swift

[iOS] get MDM settings from system dictionary in swift

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

詳全文:

相關文章: