Getting Started
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-wifi`
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/wifi/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-Assisted セットアップを使用してプラグインをインストールできます。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-wifi` plugin in my project.Manual Setupを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください:
bun add @capgo/capacitor-wifibunx cap syncインポート
「インポート」のセクションimport { CapacitorWifi } from '@capgo/capacitor-wifi';APIの概要
「APIの概要」のセクションaddNetwork
「addNetwork」のセクションWi-Fiネットワークを追加するシステムダイアログを表示します。 Android SDK 30+では、システムWi-Fi設定を開き、ネットワークを事前に埋め込んでいます。 iOSでは、直接ネットワークに接続します。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
await CapacitorWifi.addNetwork({ ssid: 'MyNetwork', password: 'mypassword', isHiddenSsid: false, securityType: NetworkSecurityType.WPA2_PSK});connect
接続Wi-Fiネットワークに接続します。 Androidでは、デフォルトではネットワークを経由してアプリのトラフィックをルーティングしない一時的な接続を作成します。 autoRouteTrafficをtrueに設定すると、接続されたネットワークにアプリのトラフィックをバインドできます (ローカル/デバイスホスト APの場合に便利)。 Androidで持続的な接続を作成するには、addNetwork()を使用してください。 iOSでは、持続的な接続を作成します。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
await CapacitorWifi.connect({ ssid: 'MyNetwork', password: 'mypassword', autoRouteTraffic: true // Android only: route app traffic through this network});disconnect
切断現在のWi-Fiネットワークから切断します。 iOSでは、このプラグインを介して追加されたネットワークのみから切断します。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
await CapacitorWifi.disconnect();getAvailableNetworks
接続可能ネットワークのリストを取得します。
Androidでのみ利用可能です。クリップボードにコピー
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { networks } = await CapacitorWifi.getAvailableNetworks();networks.forEach(network => { console.log(`SSID: ${network.ssid}, Signal: ${network.rssi} dBm`);});getIpAddress
クリップボードにコピー__CAPGO_KEEP_0__の現在のIPアドレスを取得します。 AndroidおよびiOS両方で利用可能です。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { ipAddress } = await CapacitorWifi.getIpAddress();console.log('IP Address:', ipAddress);getRssi
「getRssi」セクション__CAPGO_KEEP_0__の現在のネットワークの受信信号強度指標(RSSI)をdBmで取得します。 Androidのみで利用可能です。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { rssi } = await CapacitorWifi.getRssi();console.log('Signal strength:', rssi, 'dBm');getSsid
「getSsid」セクション__CAPGO_KEEP_0__の現在のネットワークのサービスセット識別子(SSID)を取得します。 AndroidおよびiOS両方で利用可能です。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { ssid } = await CapacitorWifi.getSsid();console.log('Connected to:', ssid);getWifiInfo
「getWifiInfo」セクション__CAPGO_KEEP_0__の現在接続中のWi-Fiネットワークに関する詳細情報を取得します。 このメソッドでは、SSID、BSSID、IPアドレス、周波数、リンクスピード、信号強度などの詳細なネットワーク情報を1つの呼び出しで取得できます。 iOSでは、あるフィールドが利用可能でない場合、未定義になります。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const info = await CapacitorWifi.getWifiInfo();console.log('Network:', info.ssid);console.log('BSSID:', info.bssid);console.log('IP:', info.ip);console.log('Frequency:', info.frequency, 'MHz');console.log('Speed:', info.linkSpeed, 'Mbps');console.log('Signal:', info.signalStrength);isEnabled
「isEnabled」セクションWi-Fiが有効になっているか確認してください。 Androidのみで利用可能です。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { enabled } = await CapacitorWifi.isEnabled();console.log('WiFi is', enabled ? 'enabled' : 'disabled');startScan
「startScan」セクションWi-Fiネットワークをスキャンしてください。 Androidのみで利用可能です。 結果は「networksScanned」イベントリスナー経由で提供されます。 注意: システムのトラッキングやハードウェアの問題により失敗する可能性があります。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
await CapacitorWifi.addListener('networksScanned', () => { console.log('Scan completed');});await CapacitorWifi.startScan();checkPermissions
「checkPermissions」セクション現在の位置情報アクセス許可の状態を確認してください。 両方のプラットフォームでWi-Fi操作に必要な位置情報許可が必要です。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const status = await CapacitorWifi.checkPermissions();console.log('Location permission:', status.location);requestPermissions
「requestPermissions」セクションユーザーから位置情報許可を要求してください。 両方のプラットフォームでWi-Fi操作に必要な位置情報許可が必要です。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const status = await CapacitorWifi.requestPermissions();if (status.location === 'granted') { console.log('Permission granted');}タイプ リファレンス
Type ReferenceAddNetworkOptions
AddNetworkOptionsネットワークの追加オプション
export interface AddNetworkOptions { /** * The SSID of the network to add * * @since 7.0.0 */ ssid: string;
/** * The password for the network (optional for open networks) * * @since 7.0.0 */ password?: string;
/** * Whether the network is hidden (Android only) * * @since 7.0.0 * @default false */ isHiddenSsid?: boolean;
/** * The security type of the network (Android only) * * @since 7.0.0 * @default NetworkSecurityType.WPA2_PSK */ securityType?: NetworkSecurityType;}ConnectOptions
ConnectOptionsネットワークへの接続オプション
export interface ConnectOptions { /** * The SSID of the network to connect to * * @since 7.0.0 */ ssid: string;
/** * The password for the network (optional for open networks) * * @since 7.0.0 */ password?: string;
/** * Whether the network is hidden (Android only) * * @since 7.0.0 * @default false */ isHiddenSsid?: boolean;
/** * Whether to automatically route app traffic through the connected Wi-Fi network (Android only) * When enabled, it binds the app process to the connected network using ConnectivityManager.bindProcessToNetwork() * This is useful for connecting to local/device-hosted APs (e.g., ESP32, IoT devices) that don't have internet access. * * @since 7.0.0 * @default false */ autoRouteTraffic?: boolean;}DisconnectOptions
DisconnectOptionsネットワークからの切断オプション
export interface DisconnectOptions { /** * The SSID of the network to disconnect from (optional) * * @since 7.0.0 */ ssid?: string;}GetAvailableNetworksResult
getAvailableNetworks()の結果getAvailableNetworks()の結果
export interface GetAvailableNetworksResult { /** * List of available networks * * @since 7.0.0 */ networks: Network[];}GetIpAddressResult
「GetIpAddressResult」セクションgetIpAddress()の結果。
export interface GetIpAddressResult { /** * The device's IP address * * @since 7.0.0 */ ipAddress: string;}GetRssiResult
「GetRssiResult」セクションgetRssi()の結果。
export interface GetRssiResult { /** * The signal strength in dBm * * @since 7.0.0 */ rssi: number;}GetSsidResult
「GetSsidResult」セクションgetSsid()の結果。
export interface GetSsidResult { /** * The SSID of the current network * * @since 7.0.0 */ ssid: string;}WifiInfo
「WifiInfo」セクションWi-Fiに関する総合情報。
export interface WifiInfo { /** * The SSID (network name) of the current network * * @since 7.0.0 */ ssid: string;
/** * The BSSID (MAC address) of the access point. * Not available on iOS. * * @since 7.0.0 */ bssid?: string;
/** * The device's IP address on the network * * @since 7.0.0 */ ip: string;
/** * The network frequency in MHz. * Not available on iOS. * * @since 7.0.0 */ frequency?: number;
/** * The connection speed in Mbps. * Not available on iOS. * * @since 7.0.0 */ linkSpeed?: number;
/** * The signal strength (0-100). * Calculated from RSSI on Android. * Not available on iOS. * * @since 7.0.0 */ signalStrength?: number;}IsEnabledResult
「IsEnabledResult」セクションisEnabled()の結果
export interface IsEnabledResult { /** * Whether Wi-Fi is enabled * * @since 7.0.0 */ enabled: boolean;}PermissionStatus
「PermissionStatus」セクション許可状態
export interface PermissionStatus { /** * Location permission state * * @since 7.0.0 */ location: PermissionState;}RequestPermissionsOptions
「RequestPermissionsOptions」セクション許可を求めるオプション
export interface RequestPermissionsOptions { /** * Permissions to request * * @since 7.0.0 */ permissions?: 'location'[];}NetworkSecurityType
「NetworkSecurityType」セクションネットワークセキュリティの種類
export enum NetworkSecurityType { /** * Open network with no security * * @since 7.0.0 */ OPEN = 0,
/** * WEP security * * @since 7.0.0 */ WEP = 1,
/** * WPA/WPA2 Personal (PSK) * * @since 7.0.0 */ WPA2_PSK = 2,
/** * WPA/WPA2/WPA3 Enterprise (EAP) * * @since 7.0.0 */ EAP = 3,
/** * WPA3 Personal (SAE) * * @since 7.0.0 */ SAE = 4,
/** * WPA3 Enterprise * * @since 7.0.0 */ WPA3_ENTERPRISE = 5,
/** * WPA3 Enterprise 192-bit mode * * @since 7.0.0 */ WPA3_ENTERPRISE_192_BIT = 6,
/** * Passpoint network * * @since 7.0.0 */ PASSPOINT = 7,
/** * Enhanced Open (OWE) * * @since 7.0.0 */ OWE = 8,
/** * WAPI PSK * * @since 7.0.0 */ WAPI_PSK = 9,
/** * WAPI Certificate * * @since 7.0.0 */ WAPI_CERT = 10,}真実の源
「真実の源」というセクションこのページはプラグインの src/definitions.tsパブリック API がアップストリームで変更された場合に再度同期を実行してください。
「Getting Started」から続けてください
「Getting Started」を使用ダッシュボードと __CAPGO_KEEP_0__ の作業を計画する場合、 「@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-wifi」を使用 「@API/__CAPGO_KEEP_1__-wifi」を使用 「@capgo/capacitor-wifi」 「@capgo/capacitor-wifi」 API まとめ API まとめの実装詳細については 導入 導入の実装詳細については API キー API キーの実装詳細については、 デバイス デバイスの実装詳細については。