Triggering Apple Shortcuts via NFC09 Jan 2019 #Hardware #iOS
In 2018, Apple released a new set of iPhones (XS, XS Max, and XR), as well as the accompanying OS updates (iOS 12). While most of the improvements were relatively minor, due to being a “tock” release in a “tick tock” cycle, Apple’s Shortcuts (previously Workflow) and Core NFC’s background tag reading functionality are two subtle new additions that provide new ways to approach task automation in iOS.
In this post, we will explore setting up NFC to trigger shortcuts for a seamless task automation flow.
The first question people usually ask is “why?”.
Shortcuts are usually activated through opening the Shortcuts app itself, the app widget, or via Siri voice commands. This requires either multiple gestures or an audible command to trigger. Through the usage of NFC tags, shortcuts can be easily triggered through a single, silent tap.
Furthermore, NFC tags can be placed to trigger shortcuts via location. For example, a NFC tag placed in a car could trigger a shortcut to start a music playlist, turn on Do-Not-Disturb mode, and open the maps app to give directions.
The possibilities are endless!
Writing to NFC tag
In order to trigger Shortcuts via NFC, we must first write some data in NDEF (NFC Data Exchange Format) to the NFC tag.
Unforunately, Core NFC on iOS does not currently support writing to NFC via iOS. Personally, I used NFC Writer by Trigger on an old android device with NFC support to write to my NFC tag.
Write the Shortcuts app URI to the NFC tag, replacing the name parameter with the name of the shortcut:
For shortcuts with inputs, you can also add an input parameter in the URI:
Note: You can open almost every app via NFC. You just need to find their URI scheme.
Reading the NFC tag
Due to a lack of hardware, background NFC tag reading is only supported on 2018 iPhones (XS, XS Max, and XR) or later. For iPhone 8/8+/X, you will need to use a NFC reader app.
After successfully writing to the NFC tag, simply touch the NFC tag with the camera area of the back of your iPhone. You should recieve a notification to open and run the shortcut you have setup.
Congratulations! 🎉 You have successfully triggered a shortcut via NFC!