跳过主内容
返回插件
@capgo/capacitor-is-root
教程
由 github.com/Cap-go

是否为根设备

检测安卓设备是否被根化或 iOS 设备是否被越狱,以增强应用安全性

指南

关于是否是根设备的教程

使用@capgo/capacitor-is-root

Capacitor 根设备检测插件

安装

bun add @capgo/capacitor-is-root
bunx cap sync

此插件暴露的内容

  • isRooted - 执行默认的根/破解检测检查。
  • isRootedWithBusyBox - 在 Android 设备上扩展默认检测,使用 BusyBox 特定的检查。
  • detectRootManagementApps - 检测是否存在已知的根管理应用程序 (仅限 Android)。
  • detectPotentiallyDangerousApps - 检测常见于根设备上的危险应用程序 (仅限 Android)。

示例用法

isRooted

执行默认的根/jailbreak 检测检查。

import { IsRoot } from '@capgo/capacitor-is-root';

const { result } = await IsRoot.isRooted();
if (result) {
  console.log('Device is rooted/jailbroken');
} else {
  console.log('Device is not rooted/jailbroken');
}

isRootedWithBusyBox

扩展默认检测以包含 BusyBox 特定检查 (仅限 Android)。

import { IsRoot } from '@capgo/capacitor-is-root';

await IsRoot.isRootedWithBusyBox();

detectRootManagementApps

检测已知的根管理应用程序是否存在 (仅限 Android)。

import { IsRoot } from '@capgo/capacitor-is-root';

await IsRoot.detectRootManagementApps();

detectPotentiallyDangerousApps

检测常见于根设备上的危险应用程序 (仅限 Android)。

import { IsRoot } from '@capgo/capacitor-is-root';

await IsRoot.detectPotentiallyDangerousApps();

完整参考