everyone.
I meet a problem when I use [NSNetServiceBrowser searchForServicesOfType: inDomain:] in iOS14.
The code :
- (void) sendData:(NSString *)data
{
NSMutableString *serviceType = [NSMutableString string];
[serviceType appendString:@"_interhdl_elmd._tcp.,"];
[serviceType appendString:data];
[_serviceBrowser searchForServicesOfType:serviceType inDomain:@""];
}
Works well in iOS13.
But it will post an error code "-72008" in the deleagate function "didNotSearch" in iOS14
- (void) netServiceBrowser:(NSNetServiceBrowser *)browser didNotSearch:(NSDictionary<NSString *,NSNumber *> *)errorDict
I know that it should add the service type in info.plist before starting a searching for service type.
key>NSBonjourServices</key>
<array>
<string>_interhdl_elmd._tcp</string>
</array>
<key>NSLocalNetworkUsageDescription</key>
<string>string for description</string>
It will success if I start a searching for service type "_interhdl_elmd._tcp". But my purpose is sending data from iPhone to the host product by the service browser functions with subtypes.( The host prouct re-write some codes of mDNS protocols to receive the data).
How can I add varible subtypes in iOS14 ?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…