スタートガイド
インストール手順と、このプラグインの完全な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アシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いのAIツールに Capgo のスキルを追加してください:
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 syncインポート
「インポート」セクションimport { CapacitorProximity } from '@capgo/capacitor-proximity';クイックスタート
「クイックスタート」セクションimport { CapacitorProximity } from '@capgo/capacitor-proximity';
const { available } = await CapacitorProximity.getStatus();if (!available) return;
await CapacitorProximity.enable();// start VoIP or voice playback UI例:ボイスメモの再生
セクション「例: 音声メモの再生」await CapacitorProximity.enable();await playVoiceNote();await CapacitorProximity.disable();よくある落とし穴
「よくある落とし穴」セクション- 常に無効化:呼び出し
disable()におけるfinallyブロックし、エラー後に明るさが復元されるようにします。 - センサー非搭載デバイス: 確認
getStatus()耳元近接UXを表示する前に。 - Web:プロキシミティAPIは公開されていないため、呼び出しはネイティブのみにしてください。
API の概要
「API 概要」セクションenable
セクション「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
「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
セクション「PluginVersionResult」プラグインのバージョンを要求した際に返される結果。
export interface PluginVersionResult { /** * Native plugin version string. * * @since 0.0.1 */ version: string;}Source of Truth
「Source Of Truth」セクションこのページはプラグインの src/definitions.tsから生成されています。upstream で公開 API が変更されたら、再度 sync を実行してください。
Getting Startedの続きを進める
「Getting Started からの続き」セクション使用している場合 スタートガイド ダッシュボードと API の運用を計画するには、これを次と連携させます @capgo/capacitor-proximity の使い方 「@capgo/capacitor-proximity」のネイティブ機能を使用する際の API の概要 「API の概要」の実装の詳細については、 はじめに 「はじめに」における実装の詳細については、 API キー および「API Keys」の実装の詳細については、 デバイス 実装の詳細については Devices を参照してください。