I’m constructing a Flutter app the place I must entry Wi-Fi data.
- Flutter: 3.32.7 (steady)
- Dart: 3.8.1
- iOS gadget: iPhone 14
- iOS model: 18.1.1
- Xcode: 16.4
What I attempted
I’m utilizing a service that mixes wifi_scan (Android) and network_info_plus
(iOS).
Right here’s the iOS-relevant a part of the code:
import 'dart:io';
import 'package deal:network_info_plus/network_info_plus.dart';
import 'package deal:permission_handler/permission_handler.dart';
class WifiNetwork {
closing String ssid;
closing int? stage;
WifiNetwork(this.ssid, {this.stage});
}
class WifiService {
closing data = NetworkInfo();
Future> getScanResults() async {
if (Platform.isIOS) {
closing ssid = await data.getWifiName();
if (ssid != null) {
print('iOS: Linked SSID is $ssid');
return [WifiNetwork(ssid)];
} else {
print('iOS: No related WiFi SSID out there');
return [];
}
}
return [];
}
}
My Information.plist accommodates:
NSLocationWhenInUseUsageDescription
This app wants location entry to learn Wi-Fi SSID.
NSLocationAlwaysAndWhenInUseUsageDescription
This app wants location entry to learn Wi-Fi SSID.
I additionally enabled the Entry Wi-Fi Info entitlement in Xcode (Capabilities → Entry Wi-Fi Info).
I’m on a paid Apple Developer account, not a private group.
Habits
On Android, wifi_scan works: I can scan all networks.
On iOS, network_info_plus.getWifiName()
all the time returns null (log: “No related WiFi SSID out there”),
regardless that:
- The cellphone is related to Wi-Fi.
- The app prompted for location permission, and I allowed it.
Location permission in Settings is Whereas Utilizing the App
, however the app doesn’t present up within the Location Providers listing beneath Settings.
I additionally tried different Wi-Fi packages (flutter_wifi_connect
, wifi_iot
), however they behave the identical — returning null.
What I anticipated
On iOS, I don’t want a listing of networks (I do know that’s not allowed). I solely must get the presently related SSID.
However even that isn’t working — it all the time comes again null.
Query
Why does network_info_plus.getWifiName()
return null on iOS regardless of having the entitlement and placement permission?
Is there any further step (e.g. exact location, provisioning profile replace, app capabilities) required to make this work?
How can I reliably fetch the related SSID on iOS with Flutter?