# React Native API

## function nativeValue(propertyName)

```javascript
let value = await Appfigurate.nativeValue('propertyName');
```

Introspect the native app's [<mark style="color:blue;">`APLConfiguration`</mark>](https://www.electricbolt.co.nz/api/Classes/APLConfiguration.html) (iOS) / [<mark style="color:blue;">`nz.co.electricbolt.appfiguratelibrary.Configuration`</mark>](https://www.electricbolt.co.nz/api/android/nz/co/electricbolt/appfiguratelibrary/Configuration.html) (Android) subclass for the `propertyName` specified. The possible types returned are: [Boolean](https://docs.electricbolt.co.nz/configuration-subclasses/supported-property-types/boolean), [String](https://docs.electricbolt.co.nz/configuration-subclasses/supported-property-types/plain-string) or [Number](https://docs.electricbolt.co.nz/configuration-subclasses/supported-property-types/double). See [supported property types](https://docs.electricbolt.co.nz/configuration-subclasses/supported-property-types) for exact conversion semantics.

## function setLogging(value)

```javascript
await Appfigurate.setLogging(true);
```

When true, Appfigurate library debugging messages will be output to the console. The default is false.

It is best practice to distribute applications via TestFlight / App Store / Google Play with logging set to false. See also [APLLogging](https://docs.electricbolt.co.nz/additional-reading/info.plist-options#apllogging) key in the (iOS, watchOS) [Info.plist](https://docs.electricbolt.co.nz/additional-reading/info.plist-options) file or (Android) [meta-data](https://docs.electricbolt.co.nz/additional-reading/androidmanifest.xml-options#apllogging) in [AndroidManifest.xml](https://docs.electricbolt.co.nz/additional-reading/androidmanifest.xml-options) file.

## function version()

```javascript
await Appfigurate.version();
```

Returns the version of the Appfigurate library in the format `major.minor.patch`. e.g. `5.1.2`

## function description()

```javascript
await Appfigurate.description();
```

Returns the textual representation of all properties.

Property names are shortened to camel case and appended with the value, except for `NSString` (Obj-C) / `String` (Swift, Java, Kotlin) properties which omit the property name.

e.g. `debugLog=5` would be returned as `DL=5`.

## function modifications()

```javascript
await Appfigurate.modifications();
```

Returns the textual representation of all properties that have non default (overridden) values.

Property names are shortened to camel case and appended with the non default value, except for `NSString` (Obj-C) / `String` (Swift, Java, Kotlin) properties which omit the property name.

e.g. `userInteractionTimeout=60.0` would be returned as `UIT=60.0`.

## function saveConfiguration()

```javascript
await Appfigurate.saveConfiguration();
```

Saves the configuration persisted in the Keychain (iOS) or EncryptedSharedPreferences (Android) into temporary storage.

Some apps have functionality to erase the Keychain or EncryptedSharedPreferences to reset apps back to *factory defaults*, which has the side effect of *removing* any Appfigurate configuration persisted in the Keychain or EncryptedSharedPreferences.

## function restoreConfiguration()

```javascript
await Appfigurate.restoreConfiguration();
```

Restores the configuration from temporary storage back into the Keychain (iOS) or EncryptedSharedPreferences (Android).

## function addListener(...)

Registers a callback that will be invoked every time Appfigurate has updated the configuration of the app. The `result` parameter is a `Map` with a single entry. The entries key is `'APLConfigurationUpdatedAction'` . The entries value is either `null` or a `String`. If `null`, then configuration was applied. If a `String`, then the an action was executed, and the value will be the name of the action.

```javascript
AppfigurateEvents.addListener('APLConfigurationUpdated', result => {
    // do something
});
```
