BlogFileMaker

NFC Scanning with FileMaker Go

By May 20, 2020 2 Comments

FileMaker Go 19 can read data from an NFC tag, which is one of the features under the “Smart AI. Smart Apps” umbrella, together with Siri Shortcuts and the use of Machine Learning models.

What is NFC?

Near-Field Communication allows for wirelessly sending small amounts of data over very short distances. Most of us use it often these days in the form of Tap-to-pay and other forms of contactless payments like Apple Pay with an Apple Watch. It is also frequently used for various keycards, perhaps to get access to the building where you work.

At its core, NFC is fascinating technology where your hardware (say your phone) supplies the power to activate a radio frequency field on an NFC tag, whose tiny radio antennas then transfer small quantities of data to your device. For this to work, your device has to be very close to the NFC tag, a distance of fewer than two inches.

NFC Power Source

The NFC tag itself is completely passive; it does not have a power source of its own. Radio waves from your device supply the power to activate it. This is one of the bigger differences with similar close-proximity communication technologies such as Bluetooth, where the ‘tag’ has its own power (usually a battery). Because of this, Bluetooth has a bigger broadcast range.

Screenshot that shows various types of NFC tags

Figure 1. Various types of NFC tags

The NFC tag holds data but not a lot of it. The data can be written to the tag in a few different formats, as specified by the “NFC Data Exchange Format” (NDEF).

It is important to note that FileMaker Go can only read a subset of all these different formats; it supports these types of content:

  • plain text
  • URL
  • XV card — which is a “Media” format of type “text/x-vCard”
  • “Smart Poster,” which is a commonly used combination of text and URL

If the NFC tag holds data in another NDEF format, then it cannot read it.

NFC on iOS

Equally important is that not all iOS devices have the hardware capability to read NFC tags, even if they can use NFC for Apple Pay. iPads, for instance, do not have this capability, nor do some of the iPhones. The information about device compatibility is fairly muddled, but this source has a good overview.

How to Read an NFC Tag

To read an NFC tag, you invoke the new script step, Configure NFC Reading. The script step has two actions: Read and Cancel. The other configurations include the script you want to run when the scan is finished (or times out), a timeout period (the default is 45 seconds), and an option to scan continuously (well suited for scanning multiple tags in quick succession).

Screenshot of the Configure NFC Reading script step

Figure 2. Configure NFC Reading script step

When you execute your script, and it reaches this script step, FileMaker Go will display the standard iOS NFC scan dialog:

Screenshot of FileMaker Go with the "Ready to Scan" dialog that says: Hold device close to the NFC tag to read it.

Figure 3. FileMaker Go waiting for the NFC scan

When you hold the phone close to an NFC tag (and remember that the iPhone NFC chip is at the top of the phone), it will read the data from the tag and run the specified script.

Screenshot of the script called when the scanning is done

Figure 4. Script called when the scanning is done

In that script, you capture the result of the scan with the Get(ScriptParameter) function.

That result contains multiple lines of information and not just the data on the tag. The FileMaker Pro help describes what is included (see Figure 5). Line 1 will tell you if the scan was successful or whether it was canceled or timed out, which is something you’ll want to parse out immediately and branch the rest of the script around. Note that not every line will always contain a value.

Screenshot from FileMaker Pro help describing whats included in the scan result

Figure 5. Information contained in the scan result

An NFC tag that contains just a string of text, for instance, will return the result, as shown in Figure 6.

Screenshot of the result from a scan containing just text

Figure 6. Result from a scan containing just text

A tag with a URL will result in, note that line 7 specifies the ‘data type.’

Screenshot that shows a tag with a URL

Figure 7. A tag with a URL

If you cancel the scan or the scan times out, you will get the results as shown in Figures 8 and 9:

Screenshot of the timeout error

Figure 8. Timeout error

Screenshot of scan canceled by the user

Figure 9. User canceled the scan

Other NFC Integrations

NFC scanning can also be integrated into your FileMaker apps in another way: Siri Shortcuts can be set up to start a flow with iOS itself, scanning a tag, rather than FileMaker Go doing the scan. Then in the Siri Shortcuts flow, you can use the new FileMaker Go 19 capability to have Siri call a script in your FileMaker app. This may prove to be useful if you need to take actions that are otherwise difficult to do from within FileMaker Go.

Next Steps with NFC in FileMaker Go

All in all, this new ability of FileMaker Go to read data from NFC tags is a very welcome addition that opens new possibilities. If you have questions or would like to enhance your FileMaker Go application, please contact our team.

Wim Decorte

Wim Decorte

Wim is a Senior Technical Solution Architect at Soliant. He is a FileMaker 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 and 18 Certified FileMaker Developer and the author of numerous Tech Briefs and articles on FileMaker Server. Wim is one of the very few multiple FileMaker Excellence Award winners and was most recently awarded the FileMaker Community Leader of the Year award at the 2015 FileMaker Developer Conference. He is also a frequent speaker at the FileMaker Developer Conference and at FileMaker Developer groups throughout the world. In addition to being a renowned expert on FileMaker Server, Wim also specializes in integrating FileMaker with other applications and systems. His pet project is the open source fmDotNet connector class that he created.

2 Comments

  • Avatar Michael says:

    Can u have a url in tag that runs a filemaker script.
    So the person doing NFC scan would not need FM GO to run the script? Run PSOS with Parameter?

    • Wim Decorte Wim Decorte says:

      Hi Michael,

      The argument is a little circular: you can’t scan NFC tags without FM Go, unless you use some other iOS app to do the scanning but without FM Go the fmp URL would have nowhere to go…
      The only way you can scan an NFC tag with a mobile device and have it do an action in FM is to communicate through the FMS Data API. Either through a custom iOS app to do the full Data API authentication and communication or by setting up your own micro web service with a URL on the NFC tag and have your micro-service do the Data API authentication and communication.

      If you want to explore these options with us, let us know.

Leave a Reply

Need to adjust your business processes quickly? We're helping clients use technology to keep their teams productive and running smoothly in these times of uncertainty. Our team can guide yours if you need help in these areas.

Talk to a Consultant