Quick information transfer via QR codes

It’s not unusual for me to want to share a URL from my Mac to my phone. Handoff makes this simple, but I’ve noticed that Handoff doesn’t always work properly; sometimes the Mac can’t find my phone for some reason. I also work with several Macs where I’m not signed into my personal iCloud account, so Handoff wouldn’t work there at all.

I use the following method to quickly transfer short bits of textual information—a link, an address, even a short note—from a Mac to my phone. On the Mac, I generate a QR code from the info. On my iPhone, I have a shortcut that reads the QR code and gives me some options regarding what to do with it. Here’s how that works.

Generating the QR code

Google had a handy URL-based API for doing this. You’d go to https://chart.googleapis.com/chart?cht=qr&chs=400x400&chl=[your info goes here] and you’d get a QR code. That still seems to work, but it’s been deprecated since 2012 (!) and is not always reliable.

There are a few other services that provide similar URL-based APIs, but fortunately, DuckDuckGo has QR code generation built in. Do a DDG search for qr https://apple.com or qr hello world and you’ll get a search results page with a QR code at the top. That’s good enough for our purposes. (Although I’ll say, hopefully unsurprisingly, that you should not use this method for any sensitive information.)

As far as URLs, I’ve found the most convenient method is to have a bookmarklet. The following gets the location of the current window, prefixes the URL with qr, and does a DuckDuckGo search to produce the QR:

javascript:(function(){location.href='https://duckduckgo.com/?q=qr+'+document.location})()

Reading the QR code

I have two shortcuts right now, one for URLs and one for other text. I could probably have combined them in some way, but these are quick hacks I wrote for my own use. They get the job done, but they’re not particularly elegant.

Hope this was useful!

A screenshot of an iOS Shortcut workflow showing the various steps: scanning the QR code, extracting the URL, and asking the user whether they want to open the URL in a browser or copy it to the clipboard.
A screenshot of an iOS Shortcut workflow showing the various steps: scanning the QR code, decoding the text, and asking the user whether they want to add the text to iOS Notes or copy it to the clipboard.

Tags: