If I use the IOKit methods to list USB devices, I can get something like "AirPod Case", but I don't know how to get "Francisco's AirPods". I've looked around a the various keys you can ask for, but none I've found bring up these "settable" names, only the standard "product names".
2 Answers
I don't know the answer as a fact, but I can give you some ideas for chasing it down:
The customised name is probably transferred as part of a higher-level protocol, or via vendor specific requests, not via standardised USB device descriptors. There is a small chance it might be advertised via a vendor specific descriptor, but this seems unlikely
I don't own any AirPods, so I don't know what kind of data protocol the AirPod case uses for communicating with a Mac, but you can try to find documentation or source code for that protocol, for example in case anyone has worked out how to use them from Linux and written a tool or library for that.
Finally, you can reverse engineer it yourself, by logging the USB traffic to and from the device when using existing software that is capable of reading the name you are after. On macOS, it's possible to do this using Wireshark. Start logging USB traffic, launch the software that talks to the device, then trawl through the logs to see if you can spot the string, then work out what request caused it to be returned.
Comments
The question is lacking some information, so I'll make some assumptions and give a few options for advancements.
By registering to USB events you can arm an iterator (io_iterator_t) and get a io_service_t object that represents the device.
From this object you can retrieve a IOUSBDeviceInterface.
An example for how to do this can be found here: https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/USBBook/USBDeviceInterfaces/USBDevInterfaces.html
From this object you can retrieve the product and vendor IDs (numbers) which by a quick search you can find which vendor and product they map to. For example: the vendor ID (VID) 0x0781 represents SunDisk.
By using the io_service_t object above, alongside IORegistryEntryCreateCFProperties you can retrieve more information.
For example, the user-friendly product and vendor names.
The product name can be retrieved by checking the key "USB Product Name" in the registry property dictionary you retrieved.
Or if the device is removable by checking the key "removable"
I haven't yet found how to get the more customizable name of the device.
However, you may be able you find it using the command line ioreg.
This command exposes the entire I/O registry and traversing it should find the value you're looking for.
Notice that ioreg does produce a lot of information, so you might want a UI to better understand what you're getting.
There are some options for downloading an I/O Registry explorer app.
You can also use your mac's System Information app to get some more user friendly information that may help you filter the information in the registry.
After you understand what node you're looking for in the I/O Registry, you can retrieve the I/O Registry object in your code and traverse the tree until you get to the desired node.