襄陽做網(wǎng)站公司電話簡單的html網(wǎng)頁制作
首先需要在配置文件申請的時候?qū)otspot勾選上,之后還要在x-code里添加對應(yīng)的配置,由于我們并沒有用到獲取設(shè)備周邊Wi-Fi的功能,所以就沒申請相關(guān)權(quán)限
相關(guān)連接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<NSString *> * array) {
? ? ? ? ? ? for (NSString * str in array) {
? ? ? ? ? ? ? ? NSLog(@"加入過的WiFi:%@",str);
? ? ? ? ? ? }
? ? ? ? }];