@capgo/capacitor-proximity

中文文档
8.1.16发布于 2026/10/15MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 4万

Capacitor plugin for enabling proximity monitoring in mobile apps.

原始使用文档
文档目录15 节
  1. ➡️ Get started for free
  2. Key features
  3. Why this plugin
  4. Platform support
  5. Compatibility
  6. Install
  7. Usage
  8. Notes
  9. Example app
  10. API
  11. enable()
  12. disable()
  13. getStatus()
  14. getPluginVersion()
  15. Interfaces

@capgo/capacitor-proximity

Blank or dim the screen when the phone is held to the ear, like the native phone app, for calls and voice messages in your Capacitor app.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-proximity in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-proximity to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-proximity for Capacitor apps

Key features

  • Enable: enable() starts proximity monitoring.
  • Disable: disable() stops it.
  • Status: getStatus() returns sensor availability and the enabled state.
  • Native sensors: UIDevice proximity monitoring on iOS. On Android, the proximity sensor dims the screen to its lowest brightness while something is close.
  • Platforms: iOS and Android. Not available on web.

Why this plugin

This plugin wraps the native proximity APIs used by iOS and Android so a Capacitor app can:

  • Enable proximity monitoring when a screen should react to the user's face or hand.
  • Disable it cleanly when the flow ends.
  • Check whether the current device supports the sensor.
  • Read the plugin version from native code.

On iOS, the plugin forwards directly to UIDevice.isProximityMonitoringEnabled. On Android, it listens to the device proximity sensor and dims the active app window while the sensor is covered.

Platform support

PlatformSupport
iOS✅ Uses native proximity monitoring
Android✅ Uses Sensor.TYPE_PROXIMITY and dims the current app window
Web❌ Not available

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8..v8..✅
v7..v7..On demand
v6..v6..❌
v5..v5..❌

The plugin major version follows the Capacitor major version.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-proximity` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

bun add @capgo/capacitor-proximity
bunx cap sync

Usage

import { CapacitorProximity } from '@capgo/capacitor-proximity';

const status = await CapacitorProximity.getStatus();

if (status.available) {
  await CapacitorProximity.enable();

  // ...run your near-ear or face-down flow...

  await CapacitorProximity.disable();
}

Notes

  • Test on a real device. Simulators and most desktop browsers do not expose a proximity sensor.
  • On Android, the plugin only affects the current app window. It does not control the full system display outside your app.
  • On iOS, Apple controls the exact screen-off behavior once proximity monitoring is enabled.

Example app

The example-app/ folder contains a small Vite demo for checking status, enabling the plugin, disabling it, and reading the native version.

API

Capacitor plugin for enabling proximity monitoring in mobile apps.

enable()

enable() => Promise<void>

Enable proximity monitoring.

On iOS this enables UIDevice.isProximityMonitoringEnabled. On Android this starts listening to TYPE_PROXIMITY and dims the current app window while the sensor is covered.

Since: 0.0.1


disable()

disable() => Promise<void>

Disable proximity monitoring.

This restores the default app window behavior and stops sensor monitoring.

Since: 0.0.1


getStatus()

getStatus() => Promise<ProximityStatusResult>

Get the current sensor availability and plugin enabled state.

Returns: Promise<ProximityStatusResult>

Since: 0.0.1


getPluginVersion()

getPluginVersion() => Promise<PluginVersionResult>

Get the current native plugin version.

Returns: Promise<PluginVersionResult>

Since: 0.0.1


Interfaces

ProximityStatusResult

Result returned by getStatus().

PropTypeDescriptionSince
availablebooleanWhether the current device exposes a usable proximity sensor.0.0.1
enabledbooleanWhether proximity monitoring is currently enabled by the plugin.0.0.1
platform'ios' | 'android' | 'web'Platform label returned by the native or web implementation.0.0.1

PluginVersionResult

Result returned when requesting the plugin version.

PropTypeDescriptionSince
versionstringNative plugin version string.0.0.1

版本与发布记录

@capgo/capacitor-proximity 共发布 16 个版本,首次发布于 2026/04/15;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.1.16latest2026/10/1525 天前
8.1.152026/10/1327 天前
8.1.142026/10/091 个月前
8.1.122026/10/081 个月前
8.1.132026/10/081 个月前
8.1.112026/09/161 个月前

关于 @capgo/capacitor-proximity 的常见问题

@capgo/capacitor-proximity 是什么?

Capacitor plugin for enabling proximity monitoring in mobile apps.

如何安装 @capgo/capacitor-proximity?

在项目目录运行 npm install @capgo/capacitor-proximity,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-proximity 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-proximity 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-proximity 可以商用吗?

@capgo/capacitor-proximity 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-proximity 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-proximity 在 2026/10/09 – 2026/11/07 这 30 天内被下载 39,894 次,日均约 1,330 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-proximity 还在维护吗?

最新版本 8.1.16 发布于 2026/10/15(25 天前);至今共发布 16 个版本,其中过去 12 个月发布了 16 个;首次发布于 2026/04/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。