首页 关于 微信公众号
欢迎关注我的微信公众号

ios开发编程辅助

获取手机连接的wifi热点名称

工作中我们经常遇到判断手机连接的是哪个热点,下面是具体代码:

#import <SystemConfiguration/CaptiveNetwork.h>

CFArrayRef myArray = CNCopySupportedInterfaces();
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
//    NSLog(@"SSID: %@",CFDictionaryGetValue(myDict, kCNNetworkInfoKeySSID));
NSString *networkName = CFDictionaryGetValue(myDict, kCNNetworkInfoKeySSID);

if ([networkName isEqualToString:@"Hot Dog"])
{
    self.storeNameController = [[StoreDataController alloc] init];
    [self.storeNameController addStoreNamesObject];
}
else {
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Connection Failed"
                                                   message: @"Please connect to the Hot Dog network and try again"
                                                  delegate: self
                                         cancelButtonTitle: @"Close"
                                         otherButtonTitles: nil];

    [alert show];

Blog

Opinion

Project

-->