Developer Notes: NFC and Claris FileMaker
DEVELOPER NOTES
Lowie Sanctobin
Hi fellow Developer!
I’ve dived into the possibilities of working with NFC Tags and Claris FileMaker recently. Leveraging the power of NFC technologie is possible thanks to a new set of functions and script steps shipped in FileMaker 19.
In this blog I’ll share some bite-sized bits of information and notes that can serve as a reference and quick overview of technical specs for fellow developers to get a jumpstart.
Have fun!
But wait, what is NFC again?
NFC (near field communication) is a set of communication protocols by which two electronic devices communicate when they are within close proximity of one another.
Some uses of NFC devices include contactless payment systems, similar to those used in credit cards and electronic ticket smart cards, and allow mobile payment to replace or supplement these systems, social networking and for sharing contacts, photos, videos, and other files. NFC devices can also act as electronic identity documents and keycards.
FileMaker Go 19 now has the ability to scan or stop scanning for NFC tags using the new script step: Configure NFC Reading
The options include an action (Read or Cancel scanning for NFC tags), a script to be run when a tag is read, an optional script parameter, an optional timeout to cancel the read operation after <n> seconds, and an optional Continuous Reading until the user cancels or the timeout parameter is met.
FileMaker Go supports NFC tags using the following formats:
“Well Known” format of type text
“Well Known” format of type URI
“Well Known” format of type “smart poster” (which is a combination of URI and text)
“Media” format of type “text/x-vCard”
FileMaker Go can read NFC tags of types 1 through 5 that contain data in the NFC Data Exchange Format (NDEF).
Claris & NFC in 19.0
NFC technology supported since version. 19.0. FileMaker GO only for now.
Since version 19.1.2 the format results as JSON .
The script step:
Script step: Configure NFC Reading (Read/Cancel) .
Purpose: Start or stop scanning for NFC tags.
Full script step documentation by Claris: https://help.claris.com/en/pro-help/content/configure-nfc.html
While testing I noticed:
This script step needs to be the last script step in your script. When other steps follow, they will be executed even before you scanned a tag. You will need to build your logic inside the script which runs after scanning (see options below)
When continuously scanning and saving the values to variable, make sure you use a global variable. The main script reruns the sub script when a tag was scanned.
Options
Script (req.)
Run a script when NFC tag is read.
! Important: In this script you must call the script step Get(ScriptParameter) to get the NFC data from the read tag.
Parameter (opt.)
Specify parameter for required script.
Timeout (opt.)
Cancels ‘read’ after specified number of seconds.
Continuous Reading (opt.)
Scanning multiple NFC tags? No problem, set a non-zero value for this option to read multiple tags.
Format Result as JSON since 19.1.2 (opt. but highly recommended)
Set value to non-zero to format the results as JSON. Easier to handle the NFC results with the built-in Filemaker JSON functions.
Useful variables while scripting
Set Variable [ $nfcdata ; Value: Get(ScriptParameter) ]
(Required in subscripts, see script option)
Set Variable [ $action ; Value: JSONGetElement ( $nfcdata ; “action” ) ]
Returns “TagRead” when a tag was read successfully.
Returns “CanceledByUser” when the user presses cancel or done.
Set Variable [ $serial ; Value: JSONGetElement ( $nfcdata ; “payloads[0].primary” ) ]
Returns the data written on the NFC tag.
Multiple payloads are possible, depends on how the tag was programmed.
Differences in device behaviour: iPhone Xs, Xr, 11, 11 Pro, 12 and 12 Pro
Read
Requires iOS 11 or later.
Background scanning (No app needed to read): iPhone Xs, Xr, 11, 11 Pro, 12 and 12 Pro
Data on the tag is required. Empty tags do nothing. (Android phones tell you the tag is empty)
Write
Requires iOS13 or later.
NFC app required to write data to a tag. (NFC tools for example)
iPhone 7, 8 and X
Read
Pre-iOS14 an app was needed. Now you can find it in the control center.
Data on the tag is required. Empty tags do nothing. (Android phones tell you the tag is empty)
Write
Requires iOS13 or later.
NFC app required to write data to a tag. (NFC tools for example)
iPhone 7 & 8 can only read with an NFC app found on the app store. (or with FM go of course)
NFC tags
Be mindful of different kinds of NFC standards. If you buy tags, make sure your phone supports them.
Only data in NDEF format can be read.
Advantages of use shortcuts in combination with NFC
Attention: NFC automation in Shortcuts app is only available on iPhone XS or newer
If you want to launch a shortcut on an older device, you will need an NFC reader/writer app (free) + you will need to write the URL shortcut on the NFC tag
https://support.apple.com/en-gb/guide/shortcuts/apd624386f42/ios
shortcuts://run-shortcut?name=[NameOfShortcut]
Security Considerations:
Write
Possible to password protect. To write, you first need to unlock the tag with the password.
Read
An NFC tag can be read by any compatible device. It’s better to not store sensitive information on an NFC tag. What you program on the tag, is your responsibility.
For our use case, we programmed some NFC tags with their own serial number.
This number is linked to assets in a secured database.
So, someone who has no business with the tag would only see the NFC tag serial number when scanned.
!Attention: to stick NFC tags to metal object, you’ll need special NFC tags
Some use cases that came to mind:
Inventory Management:
Tracking and identifying assets, inventory, …
Scanning lend items out and in, …
NFC can be valuable alternative to barcodes:
Data instead of text
Make items ‘smart’
Waterproof
Easily reprogrammable if there’s a mistake
No need to pair devices
Very fast when multiple scanning. No need to focus camera for example
Sources:
https://help.claris.com/en/pro-help/content/configure-nfc.html
https://seritag.com/news/ios14-iphone-nfc-reader
https://seritag.com/learn/nfc-enabled-phones/
https://help.gototags.com/article/writing-nfc-tags-iphone/
https://skeletonkey.com/nfc-near-field-communication-in-claris-filemaker-go-19/