fixed ios wifi part support. retry 9.
This commit is contained in:
1 parent
a229e05186
commit
1c5946620f
4 files changed
+53
-3
No files matched your search
@@ -294,12 +294,27 @@ static NSString * const BluememeDeviceKeyDefaultsKey = @"bluememe_utils_device_k
|
||||
BOOL isWep = [security isEqualToString:@"wep"] || [self boolFromDictionary:options key:@"isWep" defaultValue:NO];
|
||||
BOOL joinOnce = [self boolFromDictionary:options key:@"joinOnce" defaultValue:defaultJoinOnce];
|
||||
BOOL hiddenSsid = [self boolFromDictionary:options key:@"hiddenSsid" defaultValue:NO];
|
||||
NSString *applicationState = [self applicationStateName];
|
||||
|
||||
if (ssid.length == 0) {
|
||||
[self sendErrorForCommand:command code:@"INVALID_WIFI_OPTIONS" message:@"ssid is required."];
|
||||
return;
|
||||
}
|
||||
|
||||
if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateActive) {
|
||||
[self sendErrorForCommand:command
|
||||
code:@"APPLICATION_NOT_ACTIVE"
|
||||
message:@"iOS WiFi configuration must be requested while the app is active in the foreground."
|
||||
details:@{
|
||||
@"ssid": ssid,
|
||||
@"security": security,
|
||||
@"joinOnce": @(joinOnce),
|
||||
@"hiddenSsid": @(hiddenSsid),
|
||||
@"applicationState": applicationState
|
||||
}];
|
||||
return;
|
||||
}
|
||||
|
||||
if (isWpa3) {
|
||||
[self sendErrorForCommand:command
|
||||
code:@"UNSUPPORTED_WIFI_SECURITY"
|
||||
@@ -348,9 +363,13 @@ static NSString * const BluememeDeviceKeyDefaultsKey = @"bluememe_utils_device_k
|
||||
@"ssid": ssid,
|
||||
@"security": security,
|
||||
@"passwordLength": @(password.length),
|
||||
@"passwordUtf8Length": @([password lengthOfBytesUsingEncoding:NSUTF8StringEncoding]),
|
||||
@"passwordAsciiPrintable": @([self isAsciiPrintableString:password]),
|
||||
@"ssidUtf8Length": @([ssid lengthOfBytesUsingEncoding:NSUTF8StringEncoding]),
|
||||
@"joinOnce": @(joinOnce),
|
||||
@"hiddenSsid": @(hiddenSsid),
|
||||
@"minimumIos": @"15.0"
|
||||
@"minimumIos": @"15.0",
|
||||
@"applicationState": applicationState
|
||||
};
|
||||
[self sendWifiApplyErrorForCommand:command error:error context:context];
|
||||
return;
|
||||
@@ -377,6 +396,36 @@ static NSString * const BluememeDeviceKeyDefaultsKey = @"bluememe_utils_device_k
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)applicationStateName
|
||||
{
|
||||
UIApplicationState state = [[UIApplication sharedApplication] applicationState];
|
||||
switch (state) {
|
||||
case UIApplicationStateActive:
|
||||
return @"active";
|
||||
case UIApplicationStateInactive:
|
||||
return @"inactive";
|
||||
case UIApplicationStateBackground:
|
||||
return @"background";
|
||||
default:
|
||||
return @"unknown";
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isAsciiPrintableString:(NSString *)value
|
||||
{
|
||||
if (value.length == 0) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
for (NSUInteger index = 0; index < value.length; index++) {
|
||||
unichar character = [value characterAtIndex:index];
|
||||
if (character < 0x20 || character > 0x7E) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)sendWifiApplyErrorForCommand:(CDVInvokedUrlCommand *)command error:(NSError *)error context:(NSDictionary *)context
|
||||
{
|
||||
NSMutableDictionary *details = [NSMutableDictionary dictionary];
|
||||
|
||||
Reference in new issue
Block a user