Skip to content

Conversation

@gvanderclay
Copy link

@gvanderclay gvanderclay commented Mar 8, 2024

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.

@gvanderclay gvanderclay force-pushed the @gvanderclay/managed-config branch 2 times, most recently from 39f0e78 to 8d49fdf Compare March 8, 2024 22:23
@gvanderclay gvanderclay marked this pull request as ready for review March 8, 2024 22:27
@gvanderclay gvanderclay force-pushed the @gvanderclay/managed-config branch from 8d49fdf to d3c67df Compare March 10, 2024 16:59
Copy link

@ddekkers ddekkers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to compile the module correctly to js, path and fs should be named imports, I think

Comment on lines +7 to +8
import fs from "fs";
import path from "path";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import fs from "fs";
import path from "path";
import * as fs from "fs";
import * as path from "path";

Comment on lines +8 to +9
import fs from "fs";
import path from "path";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import fs from "fs";
import path from "path";
import * as fs from "fs";
import * as path from "path";

@roeycohen
Copy link

hi @gvanderclay, are you going to reply/fix ddeckers review?

@roeycohen
Copy link

roeycohen commented Apr 12, 2025

hi @gvanderclay,

I've tried your plugin it does great job updating AndroidManifest.xml and creating app_restrictions.xml, but when i'm trying to use it with react-native-emm i'm getting this error on AES:

...
> Task :react-native-async-storage_async-storage:javaPreCompileDebug
> Task :mattermost_react-native-emm:compileDebugKotlin
e: file:///home/expo/workingdir/build/node_modules/@mattermost/react-native-emm/android/src/newarch/java/com/EmmModule.kt:14:1 Class 'EmmModule' is not abstract and does not implement abstract base class member public abstract fun applyBlurEffect(radius: Double): Unit defined in com.mattermost.emm.NativeEmmSpec
e: file:///home/expo/workingdir/build/node_modules/@mattermost/react-native-emm/android/src/newarch/java/com/EmmModule.kt:104:3 'applyBlurEffect' overrides nothing
e: file:///home/expo/workingdir/build/node_modules/@mattermost/react-native-emm/android/src/newarch/java/com/EmmModule.kt:104:48 An overriding function is not allowed to specify default values for its parameters
> Task :mattermost_react-native-emm:compileDebugKotlin FAILED
> Task :app:mergeDebugResources
> Task :react-native-async-storage_async-storage:compileDebugJavaWithJavac
/home/expo/workingdir/build/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java:84: warning: [removal] onCatalystInstanceDestroy() in NativeModule has been deprecated and marked for removal
  public void onCatalystInstanceDestroy() {
              ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/expo/workingdir/build/node_modules/@react-native-async-storage/async-storage/android/src/javaPackage/java/com/reactnativecommunity/asyncstorage/AsyncStoragePackage.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
> Task :expo-modules-core:compileDebugKotlin
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mattermost_react-native-emm:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 2m 36s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.10.2/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
465 actionable tasks: 465 executed
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

were you able to run EXPO 52 with emm? are there any more changes one should do in order to make it work with EXPO?

Thanks 🙏

-- edit
this issue happens only on v > 1.6.0 of react-native-emm extension.
author is aware: mattermost/react-native-emm#20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants