|
| 1 | +# @config-plugins/managed-config |
| 2 | + |
| 3 | +Expo Config Plugin to auto-configure [Managed Configurations](https://developer.android.com/work/managed-configurations) on Android, facilitating the integration with Mobile Device Management (MDM) solutions like [Microsoft Intune](https://www.microsoft.com/en-us/mem/intune) and [VMware Workspace ONE](https://www.vmware.com/products/workspace-one.html). This allows enterprises to remotely manage and configure apps. It can be used with libraries such as [react-native-emm](https://github.com/mattermost/react-native-emm) or [react-native-mdm](https://github.com/robinpowered/react-native-mdm) to allow your app to be managed by an MDM solution. |
| 4 | + |
| 5 | +## Expo Installation |
| 6 | + |
| 7 | +> Note: This package cannot be utilized in the "Expo Go" app due to its reliance on custom native code, as detailed in Expo's [customizing the build process guide](https://docs.expo.io/workflow/customizing/). |
| 8 | +
|
| 9 | +First, install the package using yarn, npm, or [`npx expo install`](https://docs.expo.io/workflow/expo-cli/#expo-install) for better version compatibility: |
| 10 | + |
| 11 | +```sh |
| 12 | +npm install @config-plugins/managed-config |
| 13 | +``` |
| 14 | + |
| 15 | +Or |
| 16 | + |
| 17 | +```sh |
| 18 | +yarn add @config-plugins/managed-config |
| 19 | +``` |
| 20 | + |
| 21 | +After installation, add the [config plugin](https://docs.expo.io/guides/config-plugins/) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array in your project's `app.json` or `app.config.js`: |
| 22 | + |
| 23 | +```json |
| 24 | +{ |
| 25 | + "expo": { |
| 26 | + "plugins": [ |
| 27 | + [ |
| 28 | + "@config-plugins/managed-config", |
| 29 | + { |
| 30 | + "restrictions": [ |
| 31 | + { |
| 32 | + "key": "test_key", |
| 33 | + "title": "Test Title", |
| 34 | + "restrictionType": "string", |
| 35 | + "description": "A test description", |
| 36 | + "defaultValue": "Default value" |
| 37 | + } |
| 38 | + // Add more restrictions as needed |
| 39 | + ] |
| 40 | + } |
| 41 | + ] |
| 42 | + ] |
| 43 | + } |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +Lastly, you'll need to rebuild your app to apply these changes. Refer to Expo's guide on ["Adding custom native code"](https://docs.expo.io/workflow/customizing/) for instructions on rebuilding your app. |
| 48 | + |
| 49 | +## API |
| 50 | + |
| 51 | +The plugin is configured through the `plugins` section of your `app.json` or `app.config.js`. The configuration object accepts a `restrictions` array, where each object represents a managed configuration that your app supports. The structure for each restriction object is as follows: |
| 52 | + |
| 53 | +### Properties |
| 54 | + |
| 55 | +- **`key`** (string): A unique identifier for the restriction. |
| 56 | +- **`title`** (string): A human-readable title for the restriction, used by the MDM solution to display to admins. |
| 57 | +- **`restrictionType`** (string): The type of the restriction. Possible values include `bool`, `string`, `integer`, `choice`, `multi-select`, `hidden`, `bundle`, and `bundle_array`. |
| 58 | +- **`description`** (optional, string): A detailed description of the restriction. |
| 59 | +- **`defaultValue`** (optional, string | boolean | number | string[] | null): The default value for the restriction. The type depends on the `restrictionType`. |
| 60 | +- **`entries`** (optional, string[]): Applicable to `choice` and `multi-select` types. An array of human-readable options. |
| 61 | +- **`entryValues`** (optional, string[]): Applicable to `choice` and `multi-select` types. An array of values corresponding to each option in `entries`. |
| 62 | + |
| 63 | +### Example: |
| 64 | + |
| 65 | +Adding a configuration for a "dark mode" setting that allows users to choose between 'enabled' and 'disabled'. |
| 66 | + |
| 67 | +```json |
| 68 | +{ |
| 69 | + "expo": { |
| 70 | + "plugins": [ |
| 71 | + [ |
| 72 | + "@config-plugins/managed-config", |
| 73 | + { |
| 74 | + "restrictions": [ |
| 75 | + { |
| 76 | + "key": "dark_mode", |
| 77 | + "title": "Dark Mode", |
| 78 | + "restrictionType": "choice", |
| 79 | + "entries": ["Enabled", "Disabled"], |
| 80 | + "entryValues": ["enabled", "disabled"], |
| 81 | + "defaultValue": "disabled", |
| 82 | + "description": "Allow users to select dark mode preference" |
| 83 | + } |
| 84 | + ] |
| 85 | + } |
| 86 | + ] |
| 87 | + ] |
| 88 | + } |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +This plugin simplifies the process of making your app manageable through MDM solutions by automating the setup of managed configurations. |
| 93 | + |
| 94 | +For further details or support, check the [official documentation](https://developer.android.com/work/managed-configurations) on managed configurations. |
0 commit comments