Flutter IOS reading wifi name using the connectivity or wifi plugin

人盡茶涼 提交于 2019-12-11 16:55:23

问题


This question is similar this question, but slightly different.

I am trying to retrieve the name of my currently connected wifi network using the Connectivity Plugin.

This answer works perfectly fine in android, and while it sounds like it should work for iOS, I am getting an exception:

PlatformException(UNAVAILABLE, wifi name unavailable, null)

Simple ex. of the code causing the exception (with the assumption I am connected to wifi, also not using an emulator):

Connectivity connectivity = Connectivity();
print(await (connectivity.getWifiName()));

My gut is telling me it may be permission related, but honestly I am not sure.

Cheers and thanks!

Edit:

I just realized, the exception above is thrown by the wifi plugin, which I was also experimenting with.

print(await (Wifi.ssid));

Connectivity simply returns null...


回答1:


I'll see if I can fix that in the plugin's code. If so, I'll get back to this answer.

However, for now, simply switching this ON on Xcode will do it: (no code change in your app required)

# on your project folder, run:
open -a xcode ./ios

On Runner > Capabilities, switch Access WiFi Information to on.

See:



来源:https://stackoverflow.com/questions/55716751/flutter-ios-reading-wifi-name-using-the-connectivity-or-wifi-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!