Sharing contacts using QR Code without requiring a network connection • AndreGarzia.com

By admin
Sharing contacts using QR Code without requiring a network connection Posted

Monday, October 23rd
DATE

, 2023

I was reading Lobste.rs website

today
DATE

and saw an intriguing post about sharing contacts using QR Codes. I have worked with that in the past and clicked the link to see the solution. The author came up with a working solution that is easy to replicate and will work well, but I want to present another solution here. One that I used a lot in

2013/2015
CARDINAL

and it still works well.

In the mentioned post, the author ends up hosting a

vCard
PRODUCT

file in a web-accessible

Github
PRODUCT

repository and then creating a QR Code with the URL to the file. A simple and elegant solution.

I used that in the past too but I noticed that there was an edge case that hurt me a lot. Some conventions and meetups have horrible internet connections. It is not unusual for a conference center, specially one full of developers carrying a multiple connected devices, to have its own network go down. Or even worse, you’re so deep inside a building that you don’t have mobile reception.

The lack of a reliable connection during events is something that happened more often

ten years ago
DATE

, but it is still a problem. You don’t need a network connection to share contacts using QR Codes.

Yes, you read that right, you can use a different format instead of URL to share contact details. The format is MeCard. This format is similar to vCard format but much more concise, wasting fewer bytes to make QR Encoding easier.

So while a vCard might look like:

BEGIN:VCARD VERSION:4.0 FN:

Simon Perreault N
PERSON

:Perreault;Simon;;;ing. jr,M.Sc. BDAY:–0203 GENDER:M EMAIL;TYPE=work:[email protected] END:VCARD

A MeCard looks like:


MECARD:N:Doe,John;TEL:13035551212;EMAIL:[email protected]
ORG

;;


Simply QR Encoding the MeCard
WORK_OF_ART

string will just work. The decoding app will see it as a valid contact card. There is no network request, no need to upload a file to a web server.

Conference Engagement App

I spent many years travelling around doing tech talks all over the world and eventually developed some throwaway apps to help me engage with people after the talks. I rewrote that app in lots of different languages, it is

one
CARDINAL

of the

first
ORDINAL

things I reimplement when learning a new language or framework.

It had

two
CARDINAL

main features.

One
CARDINAL

was to allow me to quickly fire an email with the topics I talked about and links to more reference material. That didn’t involve a request either. It would simply load markdown files into a very long mailto: URL and open the default mail client pre-filled with the information. I would just need to press send and the email would sit on my outbox until a stable connection was available. Also, it helped exchanging emails with people.

Sending topics relevant to my talk was easy…

The other feature was just contact sharing, which used a MeCard generated from data stored in localStorage.

Sharing contact was also easy

This app was developed for FirefoxOS so it would be installed and offline-

first
ORDINAL

on the phone.

And it still works, look at the iPhone cam recognising the contact.

The source for that app is online. Be aware that this is something I threw together for my own personal usage. This is not production code such as you’d see working on a proper job. It still do the job though.