Check In MySejahtera Like A Pro

Tiring of scanning MySejahtera QR code here and there? And somemore you need to check out?

In this engineering blog, we will share about on how to use Siri AI, NFC and iBeacon to check in and check out via MySejahtera seamlessly.

Disclaimer: Note that this is a prototype, and not a real product, despite it is proven technically feasible.

 

For the first part, we need to understand how MySejahtera works, hence we have used some tools to understand the API for check in and check out:

This is the API request for check in alone:

{“tenant”:”tenantId”,”location”:”locationId”,”createdDate”:”2021-09-05T04:35:31.886Z”,”userStatus”:”Low”,”id”:”152067c5892e459cb4456fa1cf443a38″,”contact”:”+Phone”,”vacStatus”:”Fully Vaccinated”,”type”:1,”name”:”Tan aik keong”}

Let’s say we check in to other location without check out, actually it is just calling the check in API to new location, probably the check out is done from server side.

This is the API request for check in with dependents:

{“tenant”:”tenantId”,”location”:”locationId”,”createdDate”:”2021-09-05T04:35:31.886Z”,”userStatus”:”Low”,”id”:”152067c5892e459cb4456fa1cf443a38″,”contact”:”+Phone”,”vacStatus”:”Fully Vaccinated”,”type”:1,”name”:”Tan aik keong, dependent A, dependent B, dependent C….”}

It’s interesting that the dependent is passed via API using comma separated string concatenation only.

And we can confirm that when opening “Check in history screen”, there is no server API call, meaning to say the check in history is cached locally and the check in screen is populated locally.

With that, we have sufficient information to implement the prototype.

We have 3 cool ideas to implement the check in:

  1. Using Siri
  2. Using NFC
  3. Using iBeacon

For Siri implementation, basically we need to implement a custom user activity, so Siri can understand it can be implemented by our app. We have some parameters here:

  1. Who check in? (the user itself? or with dependents?)
  2.  Check in to where? (you can define some common places, like default is office, then can add your favorite restaurants or others)

In a chatbot/AI context, the intent is “check in”, and who and where will be the entities. Then these are the development items that we need to work on:

  • Create intent definition file with the parameters
  • Find a place in your code to “donate” the interaction shortcut
  • Enable Siri capability from main app target
  • Add an Intents Extension
  • Then use Shortcuts app to connect the voice command to the app

For NFC implementation, it’s relatively straight forward, the tricky part is to have a universal app link support. As the newer iPhones can directly support opening of URL if the NFC tag is a URL. For those who have experience implementing iOS Apple-App-Site-Association file, you will know the pain points. Hence, Firebase Dynamic Links or Branch.io is really the saviour. It can help you to handle all the hassles behind.

 

With that, basically we just need to definite each merchant to have a unique identifier in our URL with check in and check out action. Then, use any NFC app to write the tag. Nowadays, NFC tags are really cheap, could be less than RM1 per piece and no need any battery. Hence, it’s really convenient for the customers to tap to check in and check out right from their table in a restaurant.

Below is a sample of NFC tags, which is just like normal stickers:

Lastly, iBeacon check in which is truly contactless and actionless. Basically you just to pass by, and it will auto check in and check out, with a notification to inform you, totally seamless. But your phones need to have iBeacon BLE support, this is relatively common nowadays. In case if you wonder, this is how an iBeacon looks like, it’s powered by 2 AA batteries.

Apple iOS comes with great iBeacon supports with region monitoring and ranging mode. For region monitoring, it can work behind the scene. However, iOS has a limitation of maximum regions can be monitored simultaneously defined by UUID. This can be overcome by UUID + Major + Minor, with the major and minor numbers (both unsigned short integer, meaning from 1 to 65535, it shall be sufficient to support many merchants.

We are using an Estimote iBeacon for prototyping purpose, the details for monitoring and handling of “didEnterRegion”, “didExitRegion” notifications are all available in their website:

https://developer.estimote.com/ibeacon/tutorial/part-2-background-monitoring/

 

As a conclusion, of course, each of the methods above have its own pro and con. For instance, NFC tag reading is only supported in certain iPhones and Android Phones. While iBeacon requires Bluetooth to be turned on. This article however suggested alternative ways of check in which provide convenience to the users and merchants based on their preferences.

Interested to build a Siri, NFC or iBeacon powered app? Speak to us today at [email protected]