Getting Started
このプラグインのインストール手順とフル マークダウン ガイドを含むセットアッププロンプトをコピーしてください。
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.
インストール
「インストール」のセクションCapacitorのAI-Assisted Setupを使用してプラグインをインストールできます。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
「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上で実行されている場合にのみ、最後のスキャンから利用可能なWi-Fiネットワークのリストを取得します。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { networks } = await CapacitorWifi.getAvailableNetworks();networks.forEach(network => { console.log(`SSID: ${network.ssid}, Signal: ${network.rssi} dBm`);});getIpAddress
セクションのタイトル:「IPアドレスの取得」デバイスの現在のIPアドレスを取得します。 AndroidおよびiOS両方で利用可能です。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { ipAddress } = await CapacitorWifi.getIpAddress();console.log('IP Address:', ipAddress);getRssi
セクションのタイトル:「RSSIの取得」Android上で実行されている場合にのみ、現在のネットワークの受信信号強度指標(RSSI)をdBm単位で取得します。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { rssi } = await CapacitorWifi.getRssi();console.log('Signal strength:', rssi, 'dBm');getSsid
「getSsid」セクション現在のネットワークのサービス セット ID (SSID) を取得します。 Android と iOS の両方で利用可能です。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { ssid } = await CapacitorWifi.getSsid();console.log('Connected to:', ssid);getWifiInfo
「getWifiInfo」セクション現在接続している Wi-Fi ネットワークに関する詳細情報を取得します。 このメソッドでは、SSID、BSSID、IP アドレス、周波数、リンク スピード、信号強度などの情報が 1 つの呼び出しで提供されます。 iOS の場合、あるフィールドが利用できない場合があり、undefined になります。
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
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const status = await CapacitorWifi.checkPermissions();console.log('Location permission:', status.location);requestPermissions
__CAPGO_KEEP_3____CAPGO_KEEP_2__
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const status = await CapacitorWifi.requestPermissions();if (status.location === 'granted') { console.log('Permission granted');}__CAPGO_KEEP_4__
__CAPGO_KEEP_5__AddNetworkOptions
__CAPGO_KEEP_6____CAPGO_KEEP_7__
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
接続オプションネットワークに接続するためのオプション.
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
切断オプションネットワークから切断するためのオプション.
export interface DisconnectOptions { /** * The SSID of the network to disconnect from (optional) * * @since 7.0.0 */ ssid?: string;}GetAvailableNetworksResult
利用可能ネットワークの結果getAvailableNetworks()の結果.
export interface GetAvailableNetworksResult { /** * List of available networks * * @since 7.0.0 */ networks: Network[];}GetIpAddressResult
IPアドレスの結果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
Section titled “許可状態”許可状態.
export interface PermissionStatus { /** * Location permission state * * @since 7.0.0 */ location: PermissionState;}RequestPermissionsOptions
Section titled “許可を要求するオプション”許可を要求するためのオプション.
export interface RequestPermissionsOptions { /** * Permissions to request * * @since 7.0.0 */ permissions?: 'location'[];}NetworkSecurityType
Section titled “ネットワークセキュリティタイプ”ネットワークセキュリティタイプ.
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. upstream の API が変更されたときに、再度 sync を実行してください。
Getting Started から続けてください。
Getting Started から続けてください。あなたが「Getting Started から続けてください。」を使用している場合 Getting Started ダッシュボードと API の作業を計画するために、接続してください。 Using @capgo/capacitor-wifi Using @capgo/capacitor-wifi のネイティブ機能の詳細 API Overview API Overview の実装詳細 Introduction Introduction の実装詳細 API キー API キーに関する実装詳細、そして デバイス デバイスに関する実装詳細