英文:
Accessing NSUserDefaults from Airwatch
问题
I am wondering if there is anything going wrong here that anyone can help with.
Airwatch 允许我们为每个应用的“assignment”组配置应用程序配置。配置以键值对的形式输入,我们还可以使用占位符,AirWatch 将插入查找值。
我已经在其中一个开发分配组上创建了一个测试配置,如下所示:
然后在我的 React Native 代码中,我可以这样访问这些键值....
import { Settings } from 'react-native';
const deviceName = Settings?.get?.('DeviceName');
const deviceUdid = Settings?.get?.('DeviceUdid');
const deviceSerialNumber = Settings?.get?.('DeviceSerialNumber');
这些值返回为 undefined。首先,有没有一种方法可以在本地测试,以排除前端是否有问题?
或者,我在这里是否做错了什么?
谢谢
英文:
I am wondering if there is anything going wrong here that anyone can help with.
Airwatch allows us to configure an app config for each “assignment” group of an app. Config is entered as key-value pairs, and we can also use placeholders for which AirWatch will insert lookup values.
I have created a test config on one of the dev assignment groups as follows:
Then in my React Native code i have access these key values like so....
import { Settings } from 'react-native';
const deviceName = Settings?.get?.('DeviceName');
const deviceUdid = Settings?.get?.('DeviceUdid');
const deviceSerialNumber = Settings?.get?.('DeviceSerialNumber');
The values are coming back undefined. Firstly, is there a way I can test locally to rule out the front end being the issue?
Or, am I doing something wrong here entirely?
Thanks
答案1
得分: 1
不能直接访问这些值。它们被添加到一个字典中,键是 com.apple.configuration.managed
。
查看 https://www.appconfig.org/ios.html
const mangedConfig = Settings?.get?.('com.apple.configuration.managed')
const deviceName = managedConfig['DeviceName']
英文:
You can't access the values directly. They are added to a dictionary under the key com.apple.configuration.managed
See https://www.appconfig.org/ios.html
const mangedConfig = Settings?.get?.('com.apple.configuration.managed')
const deviceName = managedConfig['DeviceName']
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论