Coronavirus Lockdown: I Learnt More About QR Codes and Made a Generator PWA
Tags: javascript, angular, webdev, pwa
Published: 2020-04-05 01:13:41

> I talk about my journey of discovering QR code detection in iOS and Android and developing a feature-rich QR code generator PWA using this knowledge.

Knowingly or unknowingly, we all have been using QR codes for a while now — to make payments, to open WhatsApp Web or open links from a print ad. In case you didn’t know, they look like this:

![A QR code that takes you to Share By Cam](https://dev-to-uploads.s3.amazonaws.com/i/413m2ponuga4t0wse7xu.png "A QR code that takes you to Share By Cam")

This pattern contains some information that one can read by pointing their phone camera at it. I recently discovered that my iPhone could detect QR codes of WiFi configurations and connect to them instantly. I sat down in amazement and wondered how much time had been wasted by all of humanity in sharing WiFi name and password with others.

Recent versions of both iOS and Android support QR code scanning in their native camera apps. I discovered the various types of QR codes supported by them — contacts, events, location, phone call and SMS to name a few — and made a PWA that generates codes for all these types. I named it [Share By Cam](https://shareby.cam) because I figured it was a great way of sharing common data; and because a camera is required to complete the circle of sharing.

![Screenshot of Share By Cam](https://dev-to-uploads.s3.amazonaws.com/i/wvti0u1z2g0kgugil2oq.png "Screenshot of Share By Cam")

I looked up existing solutions and found one or more of the following problems with them:

1. They didn’t cover all types
2. They had complicated forms
3. They served too many ads
4. They sent data to a server
5. They did not work offline
6. They were not responsive

This list gave birth to the primary list of features of Share By Cam.

#### 1. Covers Most Types

I couldn’t find any official documentation from Apple or Google that listed the types of QR codes their OS could detect. I scoured the internet for all available QR code generators and made a union list and built them:

- Contact (vCard)
- Email
- Event (iCalendar)
- Link
- Location
- Phone Call
- SMS
- Text
- WiFi

> A developer can also embed an app’s deeplinks (via Text) and initiate actions, making the possibilities infinite.

I also added WhatsApp Message via deeplinking since it is a popular activity that people do.

#### 2. Simpler Forms

I added descriptive pre-filled values and verbose labels wherever necessary. I also attached short videos that explained the process succinctly.

![WiFi form of Share By Cam](https://dev-to-uploads.s3.amazonaws.com/i/46pw9676mldpp9qgnopo.png "WiFi form of Share By Cam")

#### 3. No Ads

Clean, focused UI.

#### 4. What Happens On Your Device, Stays On Your Device

I used [this](https://github.com/cordobo/angularx-qrcode) library to generate QR codes on the device itself. The data isn’t stored or sent anywhere — not to the URL, not to the local storage and most importantly, not outside your device.

#### 5. Progressive Web App (PWA) for Offline Experience

By making the app a PWA, I enabled installing it as a native app. It also gained the ability to work in airplane mode.

![“Add to Home Screen” adds the web app as a native app to iOS home screen](https://dev-to-uploads.s3.amazonaws.com/i/jvlgjpiu2xmizyu1mqwr.PNG "“Add to Home Screen” adds the web app as a native app to iOS home screen")

![Share By Cam working in airplane mode](https://dev-to-uploads.s3.amazonaws.com/i/l3w4dncaqh3bl8jecov4.PNG "Share By Cam working in airplane mode")

#### 6. Responsive Both Ways

Most people worry about just laptop, tablet and phone screens. I ensured that Share By Cam looked great on larger screens too.

![Share By Cam on larger screens](https://dev-to-uploads.s3.amazonaws.com/i/jsgzfhx3v5x4hqiq9fbe.png "Share By Cam on larger screens")

QR codes speed-up the process of data sharing and also remove human error in doing so. Besides using a WiFi QR code to help guests join your network, I also recommend you have an emergency phone call QR code on your fridge or your desk, so you can call it during emergencies instead of looking for the contact buried in your phone. A contact QR code stuck at the back of your phone will also help others save your name and number properly.

---

I enjoyed writing this PWA and hope you will automate some aspect of your life using it.