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

+3 -2
View File
@@ -103,7 +103,7 @@ WiFi options:
- `ssid`:必填 - `ssid`:必填
- `password`:开放网络可省略 - `password`:开放网络可省略
- `security`:`open`、`wep`、`wpa2`、`wpa3`,默认按是否存在 password 推断为 `open` 或 `wpa2` - `security`:`open`、`wep`、`wpa2`、`wpa3`,默认按是否存在 password 推断为 `open` 或 `wpa2`
- `hiddenSsid`:可选;Android 支持隐藏 SSID;iOS 13+ 会设置 `NEHotspotConfiguration.hidden` - `hiddenSsid`:可选;Android 支持隐藏 SSID;iOS 15+ 会设置 `NEHotspotConfiguration.hidden`
- `bssid`:可选,仅 Android 10+ 临时连接使用 - `bssid`:可选,仅 Android 10+ 临时连接使用
- `joinOnce`:可选,仅 iOS;`connectWifi` 默认 `true`,`saveWifi` 默认 `false` - `joinOnce`:可选,仅 iOS;`connectWifi` 默认 `true`,`saveWifi` 默认 `false`
@@ -210,7 +210,8 @@ Android WiFi:
iOS WiFi: iOS WiFi:
- 使用 `NEHotspotConfiguration`。 - 使用 `NEHotspotConfiguration`,当前插件 WiFi 功能要求 iOS 15+。
- 插件将 iOS deployment target 设置为 `15.0`;如果宿主 App 或构建平台覆盖该值,需要在宿主配置中同步设置 iOS 最低版本为 15.0 或更高。
- 插件会向 Cordova iOS entitlements 写入 `com.apple.developer.networking.HotspotConfiguration`,但仍必须在 Apple Developer App ID 中开启 `Hotspot Configuration` capability,并使用包含该 capability 的 provisioning profile 重新构建。 - 插件会向 Cordova iOS entitlements 写入 `com.apple.developer.networking.HotspotConfiguration`,但仍必须在 Apple Developer App ID 中开启 `Hotspot Configuration` capability,并使用包含该 capability 的 provisioning profile 重新构建。
- 如果 iOS 返回 `NEHotspotConfigurationErrorDomain` code `8` / `internal error`,优先检查 App ID、entitlements、provisioning profile 是否都包含 `Hotspot Configuration`,并确认是在真机前台运行,不是在模拟器中测试。 - 如果 iOS 返回 `NEHotspotConfigurationErrorDomain` code `8` / `internal error`,优先检查 App ID、entitlements、provisioning profile 是否都包含 `Hotspot Configuration`,并确认是在真机前台运行,不是在模拟器中测试。
- iOS 的 `NEHotspotConfiguration` password initializer 公开支持 WEP/WPA/WPA2 Personal。WPA2/WPA3 mixed 通常应先按 `security: "wpa2"` 测试;如果 WPA2-only 可用但 mixed 不可用,需要调整热点兼容性配置或改用配置描述文件/MDM 流程。 - iOS 的 `NEHotspotConfiguration` password initializer 公开支持 WEP/WPA/WPA2 Personal。WPA2/WPA3 mixed 通常应先按 `security: "wpa2"` 测试;如果 WPA2-only 可用但 mixed 不可用,需要调整热点兼容性配置或改用配置描述文件/MDM 流程。
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "bluememe-utils", "name": "bluememe-utils",
"version": "0.1.4", "version": "0.1.5",
"description": "Cordova utilities for WiFi, Firebase Cloud Messaging, and biometric unlock for OutSystems 11 apps.", "description": "Cordova utilities for WiFi, Firebase Cloud Messaging, and biometric unlock for OutSystems 11 apps.",
"license": "MIT", "license": "MIT",
"files": [ "files": [
+3 -1
View File
@@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
id="bluememe-utils" id="bluememe-utils"
version="0.1.4"> version="0.1.5">
<name>bluememe-utils</name> <name>bluememe-utils</name>
<description>Cordova utilities for WiFi, Firebase Cloud Messaging, and biometric unlock.</description> <description>Cordova utilities for WiFi, Firebase Cloud Messaging, and biometric unlock.</description>
<license>MIT</license> <license>MIT</license>
@@ -72,6 +72,8 @@
</platform> </platform>
<platform name="ios"> <platform name="ios">
<preference name="deployment-target" value="15.0" />
<config-file target="config.xml" parent="/*"> <config-file target="config.xml" parent="/*">
<feature name="BluememeUtils"> <feature name="BluememeUtils">
<param name="ios-package" value="CDVBluememeUtils" /> <param name="ios-package" value="CDVBluememeUtils" />
+35 -28
View File
@@ -75,11 +75,11 @@ static NSString * const BluememeDeviceKeyDefaultsKey = @"bluememe_utils_device_k
return; return;
} }
if (@available(iOS 11.0, *)) { if (@available(iOS 15.0, *)) {
[[NEHotspotConfigurationManager sharedManager] removeConfigurationForSSID:ssid]; [[NEHotspotConfigurationManager sharedManager] removeConfigurationForSSID:ssid];
[self sendSuccessForCommand:command dictionary:@{@"ssid": ssid, @"removed": @YES}]; [self sendSuccessForCommand:command dictionary:@{@"ssid": ssid, @"removed": @YES}];
} else { } 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; return;
#endif #endif
if (@available(iOS 11.0, *)) { if (@available(iOS 15.0, *)) {
NEHotspotConfiguration *configuration = nil; NEHotspotConfiguration *configuration = nil;
if (isOpen) { if (isOpen) {
configuration = [[NEHotspotConfiguration alloc] initWithSSID:ssid]; configuration = [[NEHotspotConfiguration alloc] initWithSSID:ssid];
} else { } else {
configuration = [[NEHotspotConfiguration alloc] initWithSSID:ssid passphrase:password isWEP:isWep]; configuration = [[NEHotspotConfiguration alloc] initWithSSID:ssid passphrase:password isWEP:isWep];
} }
if (@available(iOS 13.0, *)) { configuration.hidden = hiddenSsid;
configuration.hidden = hiddenSsid;
}
configuration.joinOnce = joinOnce; configuration.joinOnce = joinOnce;
[[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:^(NSError *error) { void (^applyConfiguration)(void) = ^{
dispatch_async(dispatch_get_main_queue(), ^{ [[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:^(NSError *error) {
if (error != nil && error.code != NEHotspotConfigurationErrorAlreadyAssociated) { dispatch_async(dispatch_get_main_queue(), ^{
NSDictionary *context = @{ 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, @"ssid": ssid,
@"security": security, @"platformMode": @"hotspotConfiguration",
@"passwordLength": @(password.length), @"connected": @YES,
@"joinOnce": @(joinOnce), @"saved": @(!joinOnce),
@"hiddenSsid": @(hiddenSsid) @"alreadyAssociated": @(error != nil && error.code == NEHotspotConfigurationErrorAlreadyAssociated)
}; };
[self sendWifiApplyErrorForCommand:command error:error context:context]; [self sendSuccessForCommand:command dictionary:result];
return; });
} }];
NSDictionary *result = @{ };
@"ssid": ssid,
@"platformMode": @"hotspotConfiguration", if ([NSThread isMainThread]) {
@"connected": @YES, applyConfiguration();
@"saved": @(!joinOnce), } else {
@"alreadyAssociated": @(error != nil && error.code == NEHotspotConfigurationErrorAlreadyAssociated) dispatch_async(dispatch_get_main_queue(), applyConfiguration);
}; }
[self sendSuccessForCommand:command dictionary:result];
});
}];
} else { } 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."];
} }
} }