安装
React Native CLI (Bare Workflow)
对于使用 React Native CLI 创建的标准 React Native 项目:
- npm
- yarn
- pnpm
npm install react-native-screenguard --save
yarn add react-native-screenguard
pnpm add react-native-screenguard
安装完成后,请继续阅读 链接 (Linking) 以进行 iOS pod 安装。
Expo 项目
需要开发构建 (Development Build)
React Native ScreenGuard 使用原生代码,无法在 Expo Go 中运行。您必须使用 开发构建 (development build)。
第 1 步:安装包
npx expo install react-native-screenguard
第 2 步:生成原生目录
运行 Prebuild 以生成原生 android 和 ios 目录:
npx expo prebuild --clean
此命令将根据您的 app.json / app.config.js 配置创建原生项目文件。