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

ios开发编程辅助

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

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

  1. #import <SystemConfiguration/CaptiveNetwork.h>
  2. CFArrayRef myArray = CNCopySupportedInterfaces();
  3. CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
  4. // NSLog(@"SSID: %@",CFDictionaryGetValue(myDict, kCNNetworkInfoKeySSID));
  5. NSString *networkName = CFDictionaryGetValue(myDict, kCNNetworkInfoKeySSID);
  6. if ([networkName isEqualToString:@"Hot Dog"])
  7. {
  8. self.storeNameController = [[StoreDataController alloc] init];
  9. [self.storeNameController addStoreNamesObject];
  10. }
  11. else {
  12. UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Connection Failed"
  13. message: @"Please connect to the Hot Dog network and try again"
  14. delegate: self
  15. cancelButtonTitle: @"Close"
  16. otherButtonTitles: nil];
  17. [alert show];

Blog

Opinion

Project