我正在使用“Objective c”
什么是:“kConfigurationKey”也用吗?
什么是:“kConfigurationServerURLKey”也用吗?
我尝试从mdm-server获取配置文件。但我无法在xcode中读取ipad中的数据。
我想要的就是将数据从mdm-server发送到设备。并将配置保存到设备中。
这是我的plist已安装:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CommandUUID</key>
<string>##CommandUUID##</string>
<key>Command</key>
<dict>
<key>RequestType</key>
<string>InstallApplication</string>
<key>ManifestURL</key>
<string>##MDM_SERVER_URL##/package/##PACKAGENO##/Manifest.plist</string>
<key>ChangeManagementState</key>
<string>Managed</string>
<key>ManagementFlags</key>
<integer>1</integer>
<key>Options</key>
<dict>
<key>NotManaged</key>
<false/>
<key>PurchaseMethod</key>
<integer>0</integer>
</dict>
<key>Configuration</key>
<dict>
<key>DeviceUUID</key>
<string>##DEVICE_UUID##</string>
<key>MDMServer</key>
<string>##MDM_SERVER##</string>
</dict>
</dict>
</dict>
</plist>
在我的Xcode中:
static NSString * const kConfigurationKey = @"com.apple.configuration.managed";
static NSString * const kConfigurationServerURLKey = @"https://???";
NSDictionary *serverConfig = [[NSUserDefaults standardUserDefaults] dictionaryForKey:kConfigurationKey]
NSString *serverURLString = serverConfig[kConfigurationServerURLKey];`
NSLog(@"config: %@", serverURLString);
这是NSLog说的(config:null)
这是您可以使用的一段代码:
NSUserDefaults *defaults= [NSUserDefaults standardUserDefaults];
if([[[defaults dictionaryRepresentation] allKeys] containsObject:@"NSLanguages"]){
//List all in NSLanguages!
NSLog(@"%@", [[NSUserDefaults standardUserDefaults] objectForKey:@"NSLanguages"]);
//Convert into Array !
NSArray* arrayNames = [[NSUserDefaults standardUserDefaults] objectForKey:@"NSLanguages"];
//print sinagle out (array)
NSLog(@"%@", arrayNames[0]);
}
您只需要将“NSLanguages”更改为“com.apple.configuration.managed”即可将standardUserDefaults转换为数组!
你有它:)