概述
概述WiFi插件,用于管理设备WiFi连接
核心功能
核心功能addNetwork- 在Android SDK 30+上,打开系统WiFi设置,网络预填充。- 在iOS上,直接连接到网络connect- 连接到WiFi网络。- 在Android上,创建一个临时连接,流量不通过网络。- 在iOS上,创建一个持久连接disconnect- 从当前WiFi网络断开连接。- 在iOS上,只断开通过此插件添加的网络getAvailableNetworks- 获取上一次扫描的可用WiFi网络列表。- 只在Android上可用
公共API
公共API| Method | Description |
|---|---|
addNetwork | Show a system dialog to add a Wi-Fi network to the device. On Android SDK 30+, this opens the system Wi-Fi settings with the network pre-filled. On iOS, this connects to the network directly. |
connect | Connect to a Wi-Fi network. On Android, this creates a temporary connection that doesn’t route traffic through the network by default. Set autoRouteTraffic to true to bind app traffic to the connected network (useful for local/device-hosted APs). For a persistent connection on Android, use addNetwork() instead. On iOS, this creates a persistent connection. |
disconnect | Disconnect from the current Wi-Fi network. On iOS, only disconnects from networks that were added via this plugin. |
getAvailableNetworks | Get a list of available Wi-Fi networks from the last scan. Only available on Android. |
getIpAddress | Get the device’s current IP address. Available on both Android and iOS. |
getRssi | Get the received signal strength indicator (RSSI) of the current network in dBm. Only available on Android. |
getSsid | Get the service set identifier (SSID) of the current network. Available on both Android and iOS. |
getWifiInfo | Get comprehensive information about the currently connected WiFi network. This method provides detailed network information including SSID, BSSID, IP address, frequency, link speed, and signal strength in a single call. On iOS, some fields may not be available and will be undefined. |
isEnabled | Check if Wi-Fi is enabled on the device. Only available on Android. |
startScan | 开始扫描Wi-Fi网络。仅在Android上可用。结果通过‘networksScanned’事件监听器传递。注意:可能由于系统限制或硬件问题而失败。 |
checkPermissions | 检查当前位置访问权限的状态。位置权限在两种平台上都需要,用于Wi-Fi操作。 |
requestPermissions | 向用户请求位置权限。位置权限在两种平台上都需要,用于Wi-Fi操作。 |
addListener | 添加‘networksScanned’事件的监听器。仅在Android上可用。该事件在Wi-Fi扫描结果可用时触发。 |
removeAllListeners | 移除此插件的所有监听器。 |
getPluginVersion | 获取本地插件版本。 |
真实来源
标题:真实来源此参考是从 src/definitions.ts 在 capacitor-wifi.
继续从@capgo/capacitor-wifi
《从@capgo/capacitor-wifi继续前进》如果您正在使用 @capgo/capacitor-wifi 来规划原生插件工作,连接它与 使用@capgo/capacitor-wifi 来实现原生能力的使用@capgo/capacitor-wifi, Capgo插件目录 来实现产品工作流程的Capgo插件目录, Capacitor由Capgo插件 来实现Capacitor由Capgo插件的细节, 添加或更新插件 来实现添加或更新插件的细节,和 Ionic 企业版插件替代品 为 Ionic 企业版插件替代品的产品工作流程。