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.
インストール
セクション:インストールCapgoの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-wifi` plugin in my project.Manual Setupを使用する場合は、以下のコマンドを実行して、下記のプラットフォーム固有の手順に従ってください。
bun add @capgo/capacitor-wifibunx cap syncImport
「Import」のセクションimport { CapacitorWifi } from '@capgo/capacitor-wifi';APIの概要
APIの概要addNetwork
__CAPGO_KEEP_0__の追加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
セクション「__CAPGO_KEEP_0__」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
セクション「__CAPGO_KEEP_0__」現在のWi-Fiネットワークから切断します。 iOSでは、追加されたネットワークのみから切断します。
import { CapacitorWifi } from '@capgo/capacitor-wifi';
await CapacitorWifi.disconnect();getAvailableNetworks
セクション「__CAPGO_KEEP_0__」最後のスキャンから利用可能な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
「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');}タイプ リファレンス
タイプ リファレンス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
ネットワークに接続するオプションネットワークに接続するオプション
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
Section titled “GetAvailableNetworksResult”getAvailableNetworks() の結果
export interface GetAvailableNetworksResult { /** * List of available networks * * @since 7.0.0 */ networks: Network[];}GetIpAddressResult
Section titled “GetIpAddressResult”getIpAddress() の結果
export interface GetIpAddressResult { /** * The device's IP address * * @since 7.0.0 */ ipAddress: string;}GetRssiResult
Section titled “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
Wi-Fi 情報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
isEnabled() の結果コピー
export interface IsEnabledResult { /** * Whether Wi-Fi is enabled * * @since 7.0.0 */ enabled: boolean;}PermissionStatus
コピーパーミッションの要求オプション
export interface PermissionStatus { /** * Location permission state * * @since 7.0.0 */ location: PermissionState;}RequestPermissionsOptions
__CAPGO_KEEP_0____CAPGO_KEEP_1__
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.tsパブリックAPIがアップストリームで変更されたときは、再度同期を実行してください。
「Getting Started」から続けてください
セクション「「Getting Started」から続けてください」あなたが使用している 「Getting Started」を使用してダッシュボードと__CAPGO_KEEP_0__のオペレーションを計画する場合、 to plan dashboard and API operations, connect it with Wi-Fi機能を使用する@capgo/capacitor-wifi native機能のWi-Fi機能を使用する@capgo/capacitor-wifi APIの概要 実装詳細のWi-Fi機能を使用する@APIの概要 概要 実装詳細の概要 APIのキー 実装詳細のWi-Fi機能を使用する@APIのキー 機器 実装詳細の機器