I'm trying to fetch all the local printer by using this way;
let serviceBrowser = NetServiceBrowser()
serviceBrowser.delegate = self
serviceBrowser.schedule(in: .current, forMode: .defaultRunLoopMode)
serviceBrowser.searchForServices(ofType: "_ipp._tcp.", inDomain:"local.")
It finds all the printers which are connected but I'd like to know the urls of them for to create UIPrinter
with URL like UIPrinter(url: URL("urlstring"))
func netServiceBrowser(_ browser: NetServiceBrowser, didFind service: NetService, moreComing: Bool) {
print(service)
// output: <NSNetService 0x1c0228960> local. _ipp._tcp. RICOH imagio MP C3302 [002673499B5F] -1
}
I don't know if using this way is a solution for to find Local/Air Printers.
Note: UIPrinterPickerController
is not an option for resolution.
You'll need to resolve the net services after you find them. Then you can do something like this to build a UIPrinter to send to AirPrint.
Here's my extension for getting txtRecord data from a NetService object: