A React Native module for identifying jail-broken, rooted, or mock locations on iOS and Android
npm install jail-monkey 
javascript
import JailMonkey from 'jail-monkey'if (JailMonkey.isJailBroken()) {
// Alternative behaviour for jail-broken/rooted devices.
}
`API
Method | Returns | Description
---|---|---
isJailBroken | boolean | is this device jail-broken/rooted.
canMockLocation | boolean | Can this device fake its GPS location.
trustFall | boolean | Checks if the device violates either isJailBroken or canMockLocation.
isDebuggedMode | Promise | Is the application is running in debug mode. Note that this method returns a Promise.iOS Only APIs
Method | Returns | Description
---|---|---
jailBrokenMessage | string | Returns the reason for jailbroken detection. Will return an empty string on Android.Android Only APIs
Method | Returns | Description
---|---|---
hookDetected | boolean | Detects if there is any suspicious installed applications.
isOnExternalStorage | boolean | Is the application running on external storage (ie. SD Card)
AdbEnabled | boolean | Is Android Debug Bridge enabled.
isDevelopmentSettingsMode | Promise | Whether user has enabled development settings on their device. Note that this method returns a Promise.
androidRootedDetectionMethods | RootedDetectionMethods | Returns an object with the results of all the Android rooted detection methods for more granular detection, this can be helpful if some devices are giving false positives.`
type RootedDetectionMethods = {
rootBeer: {
detectRootManagementApps: boolean;
detectPotentiallyDangerousApps: boolean;
checkForSuBinary: boolean;
checkForDangerousProps: boolean;
checkForRWPaths: boolean;
detectTestKeys: boolean;
checkSuExists: boolean;
checkForRootNative: boolean;
checkForMagiskBinary: boolean;
},
jailMonkey: boolean;
}
`On iOS all of the Android only methods will return
false or Promise where appropriate.$3
Install
`bash
npm i jail-monkey --save
react-native link # Not required as of React Native 0.60.0
`
for iOS:
`bash
cd ios && pod install
`If you use
rnpm, you may have trouble as rnpm does not link Android properly after 0.29.0!Note: On Android you should include
location.isFromMockProvider() from your location provider to compliment JailMonkey.canMockLocation()`. Most react-native location libraries already have this check built inSpecial thanks to this fantastic blog article: http://blog.geomoby.com/2015/01/25/how-to-avoid-getting-your-location-based-app-spoofed/