访问Airwatch中的NSUserDefaults

huangapple go评论72阅读模式
英文:

Accessing NSUserDefaults from Airwatch

问题

I am wondering if there is anything going wrong here that anyone can help with.

Airwatch 允许我们为每个应用的“assignment”组配置应用程序配置。配置以键值对的形式输入,我们还可以使用占位符,AirWatch 将插入查找值。

我已经在其中一个开发分配组上创建了一个测试配置,如下所示:

访问Airwatch中的NSUserDefaults

然后在我的 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:

访问Airwatch中的NSUserDefaults

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']

huangapple
  • 本文由 发表于 2023年2月27日 08:50:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/75575977.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定