使用React Native中的Jail Monkey检查设备是否越狱/ROOT失败,模块未定义。

5
在React Native中,我找到了两个插件来检查设备(iOS/Android)是否越狱/ROOT:
  1. Jail Monkey
  2. react-native-is-device-rooted
我首先尝试了npm包react-native-is-device-rooted,但它不起作用,并且似乎已经过时。所以我尝试使用Jail Monkey,但是我遇到了以下错误: enter image description here 代码如下:
import JailMonkey from 'jail-monkey'

export default class Welcome extends Component {
    render() {
        return (
                ...
                <View style={styles.lowerView}>
                    <CustomButton text={"Jail Monkey"} onPress={() => this.printJailMonkey()}/>
                </View>
                ...
        );
    }

    printJailMonkey = () => {
        console.log("Jail Monkey library content: " + JailMonkey.isJailBroken())
    }
}

我仔细检查了包的手册链接(使用 Xcode,pod install 等),但没有任何作用,有人能帮忙吗?

3个回答

1
JailMonkey使用本地模块,因此无法在Expo托管的应用中运行。您需要将其弹出到ExpoKit才能使JailMonkey正常工作。

1
我没有使用Expo。 - shogitai
这个答案已经过时了。只要你使用EAS Build构建,JailMonkey应该可以在Expo托管的应用程序中正常工作。 - Wodin

1
已解决,但需要手动进行链接。

嗨,我已经调试了一段时间了。你还记得你在这里说手动链接时做了什么吗?当我添加pod 'jail-monkey'时,react-native link没有更新我的podfile,我得到了双重的react-native导入。谢谢。 - Jordin Vell

1

尝试按照以下步骤手动链接。
在终端中导航到根文件夹,输入以下命令:

  1. react-native link
  2. cd ios
  3. pod update

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接