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.
インストール
「インストール」というセクション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 セットアップを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-wifibunx cap syncimport { CapacitorWifi } from '@capgo/capacitor-wifi';API の概要
Section titled “API の概要”addNetwork
Section titled “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
Section titled “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
Section titled “disconnect”現在の Wi-Fi ネットワークから切断します。 iOS では、このプラグインを介して追加されたネットワークのみから切断します。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
await CapacitorWifi.disconnect();getAvailableNetworks
「getAvailableNetworks」セクション最後のスキャンから利用可能なWi-Fiネットワークのリストを取得します。 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
「getIpAddress」セクションデバイスの現在のIPアドレスを取得します。 AndroidとiOS両方で利用可能です。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { ipAddress } = await CapacitorWifi.getIpAddress();console.log('IP Address:', ipAddress);getRssi
「getRssi」セクション現在のネットワークの受信信号強度指標(RSSI)をdBm単位で取得します。 Androidのみで利用可能です。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
const { rssi } = await CapacitorWifi.getRssi();console.log('Signal strength:', rssi, 'dBm');getSsid
「getSsid」セクション現在のネットワークのサービスセット識別子(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
セクションのタイトル:startScanWi-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 Reference
「Type Reference」セクションのタイトルAddNetworkOptions
「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
「GetAvailableNetworksResult」セクション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
Section titled “GetSsidResult”getSsid()の結果
export interface GetSsidResult { /** * The SSID of the current network * * @since 7.0.0 */ ssid: string;}WifiInfo
Section titled “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
Section titled “IsEnabledResult”isEnabled()の結果
export interface IsEnabledResult { /** * Whether Wi-Fi is enabled * * @since 7.0.0 */ enabled: boolean;}PermissionStatus
Section titled “PermissionStatus”許可状況
export interface PermissionStatus { /** * Location permission state * * @since 7.0.0 */ location: PermissionState;}RequestPermissionsOptions
リクエストパーミッションオプションパーミッションのリクエストのためのオプション
export interface RequestPermissionsOptions { /** * Permissions to request * * @since 7.0.0 */ permissions?: 'location'[];}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.tsAPI のアップストリームでパブリックが変更された場合に再度 Sync を実行してください。
Getting Started から続けて
Getting Started から続けてCapgoを使用している場合 Getting Started APIと連携してダッシュボードとAPIの操作を計画する capgo/capacitor-wifiを使用する Capacitorのネイティブ機能を使用するためにcapgo/capacitor-wifiを使用する APIの概要 APIの実装詳細 Capgoの概要 Capgoの実装詳細 API Keys for the implementation detail in API Keys, and Capgoのキーの実装詳細 デバイスの実装詳細について。