Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
396 views
in Technique[技术] by (71.8m points)

nsnetservicebrowser - How can I start a service browser for serarching services type with a varible subtypes in iOS14

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 ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...