iOS自动连接已知Wi-Fi功能的实现

首先需要在配置文件申请的时候将hotspot勾选上,之后还要在x-code里添加对应的配置,由于我们并没有用到获取设备周边Wi-Fi的功能,所以就没申请相关权限

相关连接Wi-Fi代码如下:

#import <NetworkExtension/NetworkExtension.h>

//无密码初始化

NEHotspotConfiguration *hotspotConfig = [[NEHotspotConfiguration alloc]initWithSSID:@"Wi-Fi名"];

//有密码初始化

NEHotspotConfiguration *hotspotConfig = [[NEHotspotConfiguration alloc]initWithSSID:@"Wi-Fi名" passphrase:@"密码" isWEP:NO];

\[NEHotspotConfigurationManager sharedManager\]applyConfiguration:hotspotConfig completionHandler:\^(NSError \* **_Nullable** error) { **if** (error \&\& error.code != 13 \&\& error.code != 7) { NSLog(@"加入失败"); }**else** **if**(error.code ==7){ NSLog(@"已取消"); }**else**{ NSLog(@"已连接"); } }\]; \[\[NEHotspotConfigurationManager sharedManager\] getConfiguredSSIDsWithCompletionHandler:\^(NSArray\ \* array) { **for** (NSString \* str **in** array) { NSLog(@"加入过的WiFi:%@",str); } }\];

相关推荐
humors2212 天前
[原创]AI工具:读取手机系统文件工具
windows·ios·安卓·鸿蒙·文件·苹果·读取
humors2212 天前
[原创]AI工具:手机文件查杀病毒工具
windows·ios·手机·安卓·鸿蒙·杀毒·苹果
2501_915918412 天前
iOS性能测试工具 Instruments、Keymob的使用方法 不局限 FPS
android·ios·小程序·https·uni-app·iphone·webview
左左右右左右摇晃2 天前
Tasker笔记
ios·iphone
恋猫de小郭3 天前
Android Studio Panda 3 发布,CMP 导致的 Gemini 输入问题
android·ide·flutter·ios·android studio
2501_915918413 天前
iOS 混淆流程 提升 IPA 分析难度 实现 IPA 深度加固
android·ios·小程序·https·uni-app·iphone·webview
Digitally3 天前
如何将文件从 Mac / 苹果笔记本传输至 iPad
macos·ios·ipad
2501_915909063 天前
React Native 上架 App Store:项目运行与审核构建的流程
android·ios·小程序·https·uni-app·iphone·webview
lzhdim3 天前
开启iphone的墙纸玻璃效果
macos·ios·objective-c·cocoa·iphone
2501_915909063 天前
苹果 Safari 浏览器抓包 页面刷新后的请求分析
android·前端·ios·小程序·uni-app·iphone·safari