Hello Fadil
Not sure on how you can prevent the app from running on an emulator, but I know a way to discover if your app is on emulator or not.
// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import "mx-global";
import { Big } from "big.js";
import DeviceInfo from 'react-native-device-info';
// BEGIN EXTRA CODE
// END EXTRA CODE
/**
* @returns {Promise.<void>}
*/
export async function JSA_IsEmulator() {
// BEGIN USER CODE
DeviceInfo.isEmulator().then((isEmulator) => {
if (isEmulator) {
console.info("EMULATOR");
alert("EMULATOR");
}
else {
console.info("NOT EMULATOR");
alert("NOT EMULATOR");
}
});
// END USER CODE
}
npm install --save react-native-device-info
After run your project you get the results below (it is a GIF animation, scroll right to see the emulator/device side by side and the correct emulator/not_emulator identification):
Maybe you canuse this lib and call the isEmulator method from the onload event on the AppEvents widget and block the usage of the app if isEmulator == true
Native Mobile Resources marketplace module offers a nanoflow activity that returns DeviceInfo object which includes the IsEmulator boolean.
Hi Fadil,
Yes, you can detect whether a Mendix Native Mobile app is running on an emulator.
The Native Mobile Resources module provides a Get device info nanoflow action, and the returned device information includes an IsEmulator Boolean attribute.
You can use this at application startup and decide whether the app should continue:
App startup
↓
Get device info
↓
IsEmulator = true?
├── Yes → Show "Emulators are not supported" message
│ → Close/stop the application flow
│
└── No → Continue to the normal application
For example, create a startup nanoflow:
NF_CheckDevice
↓
Get device info
↓
Decision: $DeviceInfo/IsEmulator
↓
true → Show message / navigate to a blocked page
false → Continue normally
This is preferable to checking the device model or Android version yourself, because Mendix already exposes IsEmulator through the supported Native Mobile Resources module.
One important distinction, though: if by "prevent" you mean security enforcement for a production application, I would not rely on emulator detection alone. IsEmulator is useful for controlling application behavior, but it should not be considered a strong security boundary because emulator detection can potentially be bypassed on a modified/rooted environment.
If your requirement is simply:
"Do not allow our app to be used on Genymotion/Android Emulator, but allow it on physical devices"
then the Get device info → IsEmulator check is the straightforward Mendix solution.
Also, Mendix itself supports using Android emulators for native mobile development/testing, including emulators such as BlueStacks or Genymotion, so this should be implemented as an application-specific restriction rather than a limitation of the Mendix Native Mobile platform.
Hope this helps.