So I figured out that to publish (announce the service) to an iOS device as a printer, I use NSNetService and set the type to _ipp._tcp
.
But in order to be recognized as an AirPrint printer the requirements include:
- AirPrint uses IPP for print management.
- AirPrint listens to mDNS (Bonjour/Avahi) for printer discovery.
- AirPrint requires a
_universal
subtype to be present in the_ipp
announcement before it will consider listing the printer. - AirPrint requires an additional TXT record, "URF", to be present and non-empty before it will consider listing the printer.
- While this URF format (see below) appears to be a future option for Apple, all current AirPrint-enabled apps seem to send print data as PDF.
- When a printer is protected by a username/password, the iTunes/AirPrint daemon will send a TXT record "air=username,password".
So I am trying to figure out how to publish the subtype and publish the TXT record under NSNetService which I haven't been able to do. Anyone have any ideas?
This link tells you how to configure avahi to allow access to your printer.
Try this article, it is easy to follow and the author responds to blog posts: http://sybaspot.com/configuring-dns-to-share-bonjour-printers-across-subnets-and-vlans-including-airprint-for-ios/
Since you do not even show a starting point or stub of your code so far, here is a different hint: you can simulate a valid, working AirPrint service announcement in your local LAN/WLAN, which will allow your iOS clients to successfully print to an existing printer (AirPrint or not).
Requirements: a Mac with OS X.
Once you got this working, you can now use something like Wireshark or
tcpdump
to capture the packages on the wire or from the air and save and analyse them.Then start coding your own application and make it so that it emits the same packages as the simulation.
The following is known to work on OS X Yosemite (10.10.x).
Assuming,...
mymac
,192.168.111.111
,abcd
(does NOT need to be AirPrint-capable!), andDefaultAuthType none
into/etc/cups/cupsd.conf
),...then you can make the
abcd
queue available to iOS clients.To test this, just execute the following command in a Terminal.app window (attention, the command will not return -- if you close the Terminal.app window, the effect of the command will be gone!):
If this works (as it should), you can easily come up with a script or cron job which executes this command (and lets it run in the background) every time the Mac is booted up. This is left as an exercise to the reader.
(You could run this very same command unchanged even from a second, completely different Mac, if the first Mac is providing the shared print queue and all the details above match the first Mac's settings...)
Background info:
The
dns-sd
command line utility is meant as a testing and development tool for everybody poking into Bonjour, mDNS (multicast DNS) and DNS-SD (DNS-based Service Discovery). It is part of every OS X system since Bonjour came to life.The
-P
parameter todns-sd
will make a Bonjour "proxy announcement" to your local LAN/WLAN. The announcement will tell potential AirPrint clients the following info:.local.
domain.Airprint-abcd
.192.168.111.111
and port631
.printers/abcd
to print to it.For details about this utility see
man dns-sd
. For more background, see dns-sd.org and these other answers.