Getting Started
复制安装提示并包含该插件的完整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.
您可以使用我们的AI辅助安装来安装插件。使用以下命令将Capgo技能添加到您的AI工具中:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下提示:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-proximity` plugin in my project.如果您更喜欢手动设置,请按照以下命令安装插件并遵循以下平台特定的说明:
bun add @capgo/capacitor-proximitybunx cap syncimport { 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”的部分禁用近距离监控。
复制到剪贴板
import { CapacitorProximity } from '@capgo/capacitor-proximity';
await CapacitorProximity.disable();getStatus
获取当前传感器可用性和插件启用状态。复制到剪贴板
import { CapacitorProximity } from '@capgo/capacitor-proximity';
const status = await CapacitorProximity.getStatus();类型参考
类型参考ProximityStatusResult
Section titled “ProximityStatusResult”Section titled “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
Section titled “PluginVersionResult”Section titled “Source Of Truth”
export interface PluginVersionResult { /** * Native plugin version string. * * @since 0.0.1 */ version: string;}This page is generated from the plugin’s
重新同步此页面时,请注意公共 __CAPGO_KEEP_0__ 上游的变化。Source Of Truth src/definitions.ts. Re-run the sync when the public API changes upstream.
继续从开始使用
标题:继续从开始使用如果您正在使用 开始使用 to plan dashboard and API operations, connect it with 使用@capgo/capacitor-proximity 为native能力在使用@capgo/capacitor-proximity API概述 为API概述中的实现细节 介绍 为介绍中的实现细节 API密钥 Capgo API Keys, 和 设备 Capgo __CAPGO_KEEP_0__ Devices.