添加权限,改为广播

This commit is contained in:
祝发冬 2023-09-03 00:17:27 +08:00
parent b6b5f90962
commit ad1e90604b
3 changed files with 38 additions and 7 deletions

View File

@ -16101,7 +16101,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 9;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = WFX8GD5HFX;
ENABLE_BITCODE = NO;
ENABLE_TESTABILITY = YES;
@ -16221,7 +16221,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 9;
CURRENT_PROJECT_VERSION = 10;
DEVELOPMENT_TEAM = WFX8GD5HFX;
ENABLE_BITCODE = NO;
ENABLE_TESTABILITY = YES;

View File

@ -8,5 +8,7 @@
<true/>
<key>com.apple.external-accessory.wireless-configuration</key>
<true/>
<key>com.apple.developer.networking.multicast</key>
<true/>
</dict>
</plist>

View File

@ -77,6 +77,11 @@
*/
- (void)connectAirKissWithSSID:(NSString *)ssidStr
password:(NSString *)password {
//
if([self validateContainsChinese:ssidStr])
{
ssidStr = [ssidStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
}
NSMutableArray *dataArray = [_airKissEncoder createAirKissEncorderWithSSID:ssidStr ? :@""
password:password ? :@""];
@ -104,11 +109,11 @@
[mData appendBytes:&value length:1];
}
NSString*host = kAirKiss_Host;
if (@available(iOS 16.0, *))
{
NSArray *arr = [_localIP componentsSeparatedByString:@"."];
host=[NSString stringWithFormat:@"%@.%@.%@.255",arr[0], arr[1], arr[2]];
}
// if (@available(iOS 16.0, *))
// {
// NSArray *arr = [_localIP componentsSeparatedByString:@"."];
// host=[NSString stringWithFormat:@"%@.%@.%@.255",arr[0], arr[1], arr[2]];
// }
[_clientUdpSocket sendData:mData
toHost:host
@ -135,6 +140,30 @@
_clientUdpSocket = nil;
_serverUdpSocket = nil;
}
- (BOOL)validateContainsChinese:(NSString *)content
{
// ^[\u4e00-\u9fa5]
// [\u4e00-\u9fa5]
NSRegularExpression *regularexpression = [[NSRegularExpression alloc]
initWithPattern:@"^[\u4e00-\u9fa5]"
options:NSRegularExpressionCaseInsensitive
error:nil];
return ([regularexpression numberOfMatchesInString:content
options:NSMatchingReportProgress
range:NSMakeRange(0, content.length)] > 0);
}
#pragma mark - Set up udp socket
- (void)setupClientUdpSocket