开始
复制一个包含安装步骤和本插件的完整 Markdown 指南的配置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-proximity`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/proximity/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
bun add @capgo/capacitor-proximitybunx cap syncimport { CapacitorProximity } from '@capgo/capacitor-proximity';API 概述
标题为“API 概述”的部分enable
Section titled “enable”启用近距离监测。
在 iOS 上,这会启用 UIDevice.isProximityMonitoringEnabled在 Android 上,这会开始监听 TYPE_PROXIMITY 并在传感器被遮盖时降低当前应用窗口的亮度。
import { CapacitorProximity } from '@capgo/capacitor-proximity';
await CapacitorProximity.enable();disable
Section titled “disable”禁用近距离监测。
这会恢复默认的应用窗口行为并停止传感器监测。
import { CapacitorProximity } from '@capgo/capacitor-proximity';
await CapacitorProximity.disable();getStatus
Section titled “getStatus”获取当前传感器可用性和插件启用状态。
import { CapacitorProximity } from '@capgo/capacitor-proximity';
const status = await CapacitorProximity.getStatus();类型参考
类型参考ProximityStatusResult
“类型参考”部分请求“ProximityStatusResult”时返回的结果 getStatus().
export interface ProximityStatusResult { /** * Whether the current device exposes a usable proximity sensor. * * @since 0.0.1 */ available: boolean;
/** * Whether proximity monitoring is currently enabled by the plugin. * * @since 0.0.1 */ enabled: boolean;
/** * Platform label returned by the native or web implementation. * * @since 0.0.1 */ platform: 'ios' | 'android' | 'web';}PluginVersionResult
“插件版本结果”部分请求插件版本时返回的结果
export interface PluginVersionResult { /** * Native plugin version string. * * @since 0.0.1 */ version: string;}真实来源
“真实来源”部分本页面是根据插件生成的 src/definitions.ts. 当 API 上游发生变化时,请重新同步。
继续从 Getting Started
标题:继续从 Getting Started如果您正在使用 Getting Started 来规划仪表板和 API 操作,请将其连接到 使用 @capgo/capacitor-proximity 为 Using @capgo/capacitor-proximity 中的原生能力 API 概述 为 API 概述 中的实现细节 介绍 为 Introduction 中的实现细节 API 键 用于 API 键 的实现细节, 设备 用于设备的实现细节。