capacitor-wifi-greatday
v1.0.2
Published
Capacitor WiFi plugin with fixed iOS SSID/BSSID support by GreatDay
Maintainers
Readme
capacitor-wifi-greatday
Fixed Capacitor WiFi plugin with proper iOS SSID/BSSID support
This plugin is a fixed version of @capgo/capacitor-wifi with corrected async handling for iOS WiFi information retrieval.
🔧 What Was Fixed
iOS Issues Fixed:
- ✅ Async callback bug in
NEHotspotNetwork.fetchCurrent- now properly waits for completion usingDispatchSemaphore - ✅ BSSID support added -
getSsid()andgetWifiInfo()now return BSSID (MAC address of access point) - ✅ Proper CLLocationManager integration - requests location permission correctly before accessing WiFi info
- ✅ Swift guard statement error - fixed "guard body must not fall through" compilation error
📦 Installation
npm install capacitor-wifi-greatday
npx cap sync🚀 Usage
import { CapacitorWifiGreatday } from 'capacitor-wifi-greatday';
// Get WiFi SSID and BSSID
const { ssid, bssid } = await CapacitorWifiGreatday.getSsid();
console.log('SSID:', ssid);
console.log('BSSID:', bssid);
// Get complete WiFi information
const wifiInfo = await CapacitorWifiGreatday.getWifiInfo();
console.log('WiFi Info:', wifiInfo);
// Returns: { ssid, bssid, ip, frequency, linkSpeed, signalStrength }
// Get IP address
const { ipAddress } = await CapacitorWifiGreatday.getIpAddress();
// Connect to WiFi network
await CapacitorWifiGreatday.connect({
ssid: 'MyNetwork',
password: 'MyPassword'
});
// Disconnect from WiFi
await CapacitorWifiGreatday.disconnect();
// Check if WiFi is enabled (Android only)
const { enabled } = await CapacitorWifiGreatday.isEnabled();
// Start WiFi scan (Android only)
await CapacitorWifiGreatday.startScan();
// Get available networks (Android only)
const networks = await CapacitorWifiGreatday.getAvailableNetworks();📱 Platform Support
| Feature | iOS | Android |
|---------|-----|---------|
| getSsid() | ✅ | ✅ |
| getWifiInfo() | ✅ | ✅ |
| getIpAddress() | ✅ | ✅ |
| connect() | ✅ | ✅ |
| disconnect() | ✅ | ✅ |
| addNetwork() | ✅ | ✅ |
| isEnabled() | ❌ | ✅ |
| startScan() | ❌ | ✅ |
| getAvailableNetworks() | ❌ | ✅ |
| getRssi() | ❌ | ✅ |
⚙️ Configuration
iOS
Add the following keys to your ios/App/App/Info.plist:
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to WiFi information</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to WiFi information in background</string>
<key>NSLocalNetworkUsageDescription</key>
<string>This app needs local network access to verify WiFi connection</string>Add the following to your entitlements files (App.entitlements, AppDebug.entitlements, AppRelease.entitlements):
<key>com.apple.developer.networking.wifi-info</key>
<true/>Android
Add the following permissions to your android/app/src/main/AndroidManifest.xml (already included in the plugin):
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />🔑 Permissions
iOS
- Location permission is required to access SSID/BSSID on iOS 13+
- WiFi Information entitlement is required
Android
- Location permission (
ACCESS_FINE_LOCATIONandACCESS_COARSE_LOCATION) is required - Runtime location permission is automatically requested by the plugin
🐛 Bug Reports
For issues and feature requests, please visit: https://github.com/nasasutisna/capacitor-wifi-greatday/issues
📄 License
MIT
👥 Authors
- GreatDay HR Team
🙏 Acknowledgments
Based on the original @capgo/capacitor-wifi plugin with critical iOS bug fixes.
