npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-device-secure-info

v1.0.1

Published

React Native native module to get device secure information including device info, memory, CPU, and battery status. Supports both Old Architecture (Bridge) and New Architecture (TurboModule).

Readme

react-native-device-secure-info

一个 React Native 原生模块,用于获取设备安全信息,包括设备基础信息、内存、CPU 和电池状态。同时支持新架构(TurboModule)旧架构(Bridge)

截图

功能特性

  • 📱 基础设备信息 — 设备名称、系统版本、品牌、制造商、设备型号、设备 ID、运营商、SDK 版本
  • 💾 内存信息 — 总内存、可用内存、已用内存、内存使用率
  • ⚙️ CPU 信息 — CPU 架构、核心数、使用率
  • 🔋 电池信息 — 电量百分比、充电状态、是否正在充电
  • 🚀 双架构支持 — 自动适配新架构(TurboModule)和旧架构(Bridge)
  • 📦 TypeScript 支持 — 完整的类型定义

平台支持

| 平台 | 支持 | | --- | --- | | iOS | ✅ | | Android | ✅ |

环境要求

  • React Native >= 0.71.0
  • React >= 18.0.0
  • iOS >= 13.4
  • Android minSdkVersion >= 21

安装

npm install react-native-device-secure-info
# 或
yarn add react-native-device-secure-info

iOS

cd ios && pod install

Android

无需额外配置,React Native CLI 的 autolinking 会自动完成链接。

使用方式

import { getDeviceInfo } from 'react-native-device-secure-info';

async function fetchInfo() {
  const info = await getDeviceInfo();

  // 基础设备信息
  console.log('设备名称:', info.deviceName);
  console.log('系统:', info.systemName, info.systemVersion);
  console.log('品牌:', info.brand);
  console.log('制造商:', info.manufacturer);
  console.log('设备型号:', info.deviceModel);
  console.log('设备ID:', info.deviceId);
  console.log('运营商:', info.carrierName);

  // 内存信息
  console.log('总内存:', info.totalMemory);
  console.log('可用内存:', info.availableMemory);
  console.log('内存使用率:', info.memoryUsagePercent + '%');

  // CPU 信息
  console.log('CPU架构:', info.cpuArchitecture);
  console.log('CPU核心数:', info.cpuCores);
  console.log('CPU使用率:', info.cpuUsagePercent + '%');

  // 电池信息
  console.log('电量:', info.batteryLevel + '%');
  console.log('充电状态:', info.batteryState);
  console.log('正在充电:', info.isCharging);
}

API

getDeviceInfo(): Promise<DeviceSecureInfo>

获取设备安全信息,返回一个 Promise,resolve 后得到 DeviceSecureInfo 对象。

DeviceSecureInfo 类型定义

interface DeviceSecureInfo {
  // ---- 基础设备信息 ----
  deviceName: string;        // 设备名称(如 "iPhone 17 Pro")
  systemVersion: string;     // 系统版本号(如 "26.2" / "14")
  brand: string;             // 设备品牌(如 "Apple" / "Samsung")
  manufacturer: string;      // 制造商(如 "Apple" / "Xiaomi")
  deviceId: string;          // 设备唯一标识
  carrierName: string;       // 运营商名称(如 "中国移动")
  sdkVersion: number;        // SDK 版本号
  deviceModel: string;       // 设备型号(如 "iPhone14,2" / "arm64")
  systemName: string;        // 系统名称(如 "iOS" / "Android")

  // ---- 内存信息 ----
  totalMemory: number;       // 总内存(字节)
  availableMemory: number;   // 可用内存(字节)
  usedMemory: number;        // 已使用内存(字节)
  memoryUsagePercent: number; // 内存使用百分比

  // ---- CPU 信息 ----
  cpuArchitecture: string;   // CPU 架构(如 "arm64")
  cpuCores: number;          // CPU 核心数
  cpuUsagePercent: number;   // CPU 使用率百分比

  // ---- 电池信息 ----
  batteryLevel: number;      // 电池电量百分比(0-100,-1 表示未知)
  batteryState: string;      // 电池状态("charging" / "discharging" / "full" / "unknown")
  isCharging: boolean;       // 是否正在充电
}

架构说明

本模块同时支持 React Native 新架构和旧架构:

| 架构 | 实现方式 | 说明 | | --- | --- | --- | | 新架构 | TurboModule + Codegen | 通过 TurboModuleRegistry 自动注册,性能更优 | | 旧架构 | NativeModules (Bridge) | 通过 NativeModules.DeviceSecureInfoModule 获取 |

模块入口(src/index.ts)会自动检测当前架构并选择对应的实现,使用者无需关心底层差异。

项目结构

react-native-device-secure-info/
├── src/
│   ├── index.ts                        # JS 入口,自动适配新旧架构
│   └── NativeDeviceSecureInfo.ts       # TurboModule Spec 定义(Codegen)
├── ios/
│   ├── DeviceSecureInfoModule.h        # iOS 旧架构头文件
│   ├── DeviceSecureInfoModule.m        # iOS 旧架构实现(Bridge)
│   ├── DeviceSecureInfoTurboModule.h   # iOS 新架构头文件
│   └── DeviceSecureInfoTurboModule.mm  # iOS 新架构实现(TurboModule)
├── android/
│   └── app/src/main/java/...
│       ├── DeviceSecureInfoModule.kt   # Android 原生模块实现
│       └── DeviceSecureInfoPackage.kt  # Android Package 注册
├── react-native-device-secure-info.podspec  # iOS CocoaPods 配置
├── react-native.config.js              # React Native autolinking 配置
└── package.json

本地开发

运行 Demo App

# 安装依赖
npm install

# iOS
cd ios && pod install && cd ..
npm run ios

# Android
npm run android

License

MIT