开始获取
复制包含安装步骤和本插件的完整 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 sync导入
导入import { CapacitorProximity } from '@capgo/capacitor-proximity';API概述
API概述enable
启用启用近距离监测
在iOS上启用 UIDevice.isProximityMonitoringEnabled在Android上开始监听 TYPE_PROXIMITY 并在感应器被遮盖时降低当前应用窗口
import { CapacitorProximity } from '@capgo/capacitor-proximity';
await CapacitorProximity.enable();disable
禁用Disable proximity monitoring.
恢复默认应用窗口行为并停止传感器监控.
import { CapacitorProximity } from '@capgo/capacitor-proximity';
await CapacitorProximity.disable();getStatus
getStatus获取当前传感器可用性和插件启用状态.
import { CapacitorProximity } from '@capgo/capacitor-proximity';
const status = await CapacitorProximity.getStatus();Type Reference
类型参考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
Copy to clipboard请求插件版本时返回的结果。
export interface PluginVersionResult { /** * Native plugin version string. * * @since 0.0.1 */ version: string;}真实数据来源
真实数据来源此页面是由插件生成的。 src/definitions.ts当公共API上游更改时,请重新运行同步。
从开始阶段继续
从开始阶段继续如果您正在使用 开始阶段 规划仪表板和API操作,请将其连接到 使用@capgo/capacitor-proximity 为native能力在使用@capgo/capacitor-proximity中 API概述 为实现细节在API概述中 介绍 为实现细节在介绍中 API密钥 为实现细节在API密钥中,和 设备 为实现细节在设备中