I have a couple of Apple devices in my network (both computers and mobile devices). I was wondering if it is possible, to get the model identifier like Macmini9,1
if I have the IP address and/or the Mac address.
I am using the NetServiceBrowser
and NetService
classes to find the devices. If the device has the AirPlay service, I can get the model identifier.
However, not all of my devices seem to implement/publish this service (it requires devices running Monterey or later and only devices 2018+ are supported). Is there a more general approach?
I saw that some apps can also get additional information from any device in the network (like the vendor name). How is it possible to get this information in a Swift based app?
macOS seems to know this information. In the Finder a specific icon is shown, so I guess the model identifier must be published somehow:
Update:
It seems like this information can be gathered using a Bonjour service called _device-info._tcp
.
I have the following code:
let service = NetService(domain: "", type: "_device-info._tcp", name: "Mac-Mini.local.")
service.delegate = self
service.startMonitoring()
I tried a specific domain ("local.") and various names (Mac-Mini, Mac-Mini.local, Mac-Mini.fritz.box) but I did not get any TXT message.
I updated the Info.plist and added the key.
Does this still work on Ventura? (well it must be, since Finder still shows the icon).
I solved the problem by using a NetService
.