iosreact-nativeairwatch

Accessing NSUserDefaults from Airwatch


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:

enter image description here

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


Solution

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