HomeiOS Developmentflutter - network_info_plus.getWifiName() returns null on iOS even with location permission and...

flutter – network_info_plus.getWifiName() returns null on iOS even with location permission and Entry Wi-Fi Data entitlement


I’m constructing a Flutter app the place I have to entry Wi-Fi info.

  • 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 'bundle:network_info_plus/network_info_plus.dart';
import 'bundle:permission_handler/permission_handler.dart';

class WifiNetwork {
  remaining String ssid;
  remaining int? stage;
  WifiNetwork(this.ssid, {this.stage});
}

class WifiService {
  remaining data = NetworkInfo();

  Future> getScanResults() async {
    if (Platform.isIOS) {
      remaining 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 Data.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 Data entitlement in Xcode (Capabilities → Entry Wi-Fi Data).
I’m on a paid Apple Developer account, not a private crew.

Conduct

On Android, wifi_scan works: I can scan all networks.
On iOS, network_info_plus.getWifiName() at all times returns null (log: “No related WiFi SSID out there”), though:

  • 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 record 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 have to get the at present related SSID.
However even that isn’t working — it at all times 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 extra 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?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments