IOS notification of wifi connection including SSID

∥☆過路亽.° 提交于 2019-12-03 11:21:17

问题


Newbie IOS programmer looking for a way to get notified when the IPhone connects to a WIFI network.

i.e. Notification for the following transitions: 3G to WIFI WIFI to 3G WIFI to another WIFI

It should be able to tell which SSID I am connected to ...

This took about 20 minutes to figure out on Android, can't find a starting point for this function on IOS

thanks


回答1:


Using the code u can get the SSID data of the WIFI you are currently connected to.

CFArrayRef myArray1 = CNCopySupportedInterfaces();
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray1, 0));
NSLog(@"%@",myDict);



回答2:


For getting notification of network changes, you could drop Apple's Reachability class into your project.

As for getting SSID's, check out the solutions in the System Configuration framework's CaptiveNetwork API (documentation linked for you).



来源:https://stackoverflow.com/questions/10792514/ios-notification-of-wifi-connection-including-ssid

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