How do I obtain “model name” for a networked device (potentially using Bonjour)?

后端 未结 2 814
无人及你
无人及你 2021-02-02 18:10

Apple\'s Finder.app is able to consistently determine the exact model of each physical computer that uses bonjour (as evidenced by the icons being unique for each individual dev

2条回答
  •  滥情空心
    2021-02-02 18:47

    OSX is broadcasting this information if certain network services are running on this machine. To my knowledge these are _afpovertcp, _rfb and _airport (Airport router only of course). You are looking for a bonjour service called _device-info._tcp. The trouble is, that it is not showing up via a simple

    [someNSNetServiceBrowserInstance searchForServicesOfType:@"_services._dns-sd._udp." inDomain:@""];
    

    Instead you need to start monitoring a specific Host which you think could broadcast _device-info._tcp.

    NSNetService *aNetService = [[NSNetService alloc]initWithDomain:@"" type:@"_device-info._tcp." name:@"MyFancyIMacWithAFPOn"];
        [aNetService setDelegate:self];
        [aNetService startMonitoring];
    

    Implement the callback

    - (void)netService:(NSNetService *)sender didUpdateTXTRecordData:(NSData *)data
    

    Which will give you the deviceModel string.

提交回复
热议问题