expo / config-plugins

Out-of-tree Expo config plugins for packages that haven't adopted the config plugin system yet.
472 stars 102 forks source link

feat(managed-config): Add Managed Config plugin (@config-plugins/mana… #228

Open gvanderclay opened 8 months ago

gvanderclay commented 8 months ago

Why

The motivation behind this PR is to provide Expo developers with a way to configure their apps for Mobile Device Management (MDM) solutions. Managed are used in apps deployed in enterprise environments, allowing IT administrators to remotely manage and configure settings within an app for users within their organization. It can be complimented with react-native-emm or react-native-mdm to integrate MDM features.

This PR introduces the @config-plugins/managed-config to @expo/config-plugins to allow MDM configuration support without being tied to a specific library.

Relevant issues and requests:

How

The @config-plugins/managed-config plugin was developed following the Expo Config Plugin system's guidelines, leveraging the Android Managed Configurations XML resource file to declare app restrictions. It parses a given set of restrictions defined in the app.json or app.config.js under the plugin options and generates the corresponding XML file at build time, which is then included in the final Android app bundle.

The plugin supports all documented restriction types (e.g., bool, string, integer, choice, multi-select, hidden, bundle, and bundle_array).

Test Plan

The plugin has been thoroughly tested with a series of unit tests covering each restriction type (bool, string, integer, choice, multi-select, hidden, bundle, bundle_array). These tests validate the XML generation logic, ensuring that the output matches the expected configuration for a given set of restrictions.

Additional manual testing was performed using the apps/app project and validating that the app_restrictions file was added, and the android manifest was modified correctly.