fixed ios wifi part support. retry 5.

This commit is contained in:
aria committed 2026-04-23 10:59:57 +09:00
1 parent 87ba9a928b
commit 0504d4058a
4 files changed
+42 -32

No files matched your search

+35 -28
View File
@@ -75,11 +75,11 @@ static NSString * const BluememeDeviceKeyDefaultsKey = @"bluememe_utils_device_k
return;
}
if (@available(iOS 11.0, *)) {
if (@available(iOS 15.0, *)) {
[[NEHotspotConfigurationManager sharedManager] removeConfigurationForSSID:ssid];
[self sendSuccessForCommand:command dictionary:@{@"ssid": ssid, @"removed": @YES}];
} else {
[self sendErrorForCommand:command code:@"UNSUPPORTED_IOS_VERSION" message:@"WiFi configuration requires iOS 11 or newer."];
[self sendErrorForCommand:command code:@"UNSUPPORTED_IOS_VERSION" message:@"WiFi configuration requires iOS 15 or newer."];
}
}
@@ -316,43 +316,50 @@ static NSString * const BluememeDeviceKeyDefaultsKey = @"bluememe_utils_device_k
return;
#endif
if (@available(iOS 11.0, *)) {
if (@available(iOS 15.0, *)) {
NEHotspotConfiguration *configuration = nil;
if (isOpen) {
configuration = [[NEHotspotConfiguration alloc] initWithSSID:ssid];
} else {
configuration = [[NEHotspotConfiguration alloc] initWithSSID:ssid passphrase:password isWEP:isWep];
}
if (@available(iOS 13.0, *)) {
configuration.hidden = hiddenSsid;
}
configuration.hidden = hiddenSsid;
configuration.joinOnce = joinOnce;
[[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error != nil && error.code != NEHotspotConfigurationErrorAlreadyAssociated) {
NSDictionary *context = @{
void (^applyConfiguration)(void) = ^{
[[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error != nil && error.code != NEHotspotConfigurationErrorAlreadyAssociated) {
NSDictionary *context = @{
@"ssid": ssid,
@"security": security,
@"passwordLength": @(password.length),
@"joinOnce": @(joinOnce),
@"hiddenSsid": @(hiddenSsid),
@"minimumIos": @"15.0"
};
[self sendWifiApplyErrorForCommand:command error:error context:context];
return;
}
NSDictionary *result = @{
@"ssid": ssid,
@"security": security,
@"passwordLength": @(password.length),
@"joinOnce": @(joinOnce),
@"hiddenSsid": @(hiddenSsid)
@"platformMode": @"hotspotConfiguration",
@"connected": @YES,
@"saved": @(!joinOnce),
@"alreadyAssociated": @(error != nil && error.code == NEHotspotConfigurationErrorAlreadyAssociated)
};
[self sendWifiApplyErrorForCommand:command error:error context:context];
return;
}
NSDictionary *result = @{
@"ssid": ssid,
@"platformMode": @"hotspotConfiguration",
@"connected": @YES,
@"saved": @(!joinOnce),
@"alreadyAssociated": @(error != nil && error.code == NEHotspotConfigurationErrorAlreadyAssociated)
};
[self sendSuccessForCommand:command dictionary:result];
});
}];
[self sendSuccessForCommand:command dictionary:result];
});
}];
};
if ([NSThread isMainThread]) {
applyConfiguration();
} else {
dispatch_async(dispatch_get_main_queue(), applyConfiguration);
}
} else {
[self sendErrorForCommand:command code:@"UNSUPPORTED_IOS_VERSION" message:@"WiFi configuration requires iOS 11 or newer."];
[self sendErrorForCommand:command code:@"UNSUPPORTED_IOS_VERSION" message:@"WiFi configuration requires iOS 15 or newer."];
}
}