Skip to content

Instantly share code, notes, and snippets.

@equipter
Last active November 10, 2024 00:49
Show Gist options
  • Save equipter/de2d9e421be9af1615e9b9cad4834ddc to your computer and use it in GitHub Desktop.
Save equipter/de2d9e421be9af1615e9b9cad4834ddc to your computer and use it in GitHub Desktop.

iOS NDEF Record Compatibility

Introduction

NDEF (NFC Data exchange format) is a method of transferring (relatively small amounts of) information from a passive or actively emulated tag by way of "records" which specify the type of information is being received and the function it is meant to have.

iPhones do not have a full suite of NDEF compatibility, the reason for this is unknown (to me at least), what this means is the background polling on iPhones will not interpret some specific record types, with compatible NDEF records, a notification will pop up directing the user to follow the received data into its respective app to complete whatever action was intended by the record.

Compatibility Table

Below are the options offered by NFC Tools on IOS for NDEF Encoding, some of the options below are other record types but with a specific function IE social links are just URLs.

Record Type Compatibility Notes
Plaintext
URL ☑️
Custom URL/URI ☑️
Unit Link ☑️ Uses a URL
Application ☑️ Uses a URL
Social Network Link ☑️ Uses a URL
Search ☑️ Uses a URL
Local File uses URI but doesnt work with iOS filesystem
Mailto ☑️ Uses URI
Contact vCard Can be overcome by linking to a hosted .vcf (contact card) file on a URL to get the same popup effect*
Phone Number ☑️ Uses URI
SMS ☑️ Uses URI
Facetime ☑️ Uses URI
Facetime Audio ☑️ Uses URI
GeoLocation ☑️ only with a compatible map format set IE apple maps
Address ☑️ only with a compatible map format set IE apple maps
Bitcoin ☑️ Requires a compatible crypto app
Bluetooth
WiFi
Data
Shortcut ☑️ Different than automations, uses URI to point at specific shortcut

vCard Contact Cards (.vcf)

The way to overcome the lack of support for .vcf records is to host a .vcf file and use a URL NDEF Record to point directly at the file, with the .vcf extension.

Note

iOS will select & run only the first compatible record it finds within a tag, meaning you can store both a vcf NDEF record in Record0 aswell as URL vcf link in Record1 for maximum online & offline compatibility for Android users who may scan your tag who are able to interpret the .vcf NDEF record natively aswell as iOS users who need the URL to receive the VCF.

Note: Google Drive does not work for this.

An easy way to achieve this is to use Gists on GitHub, I recommend using a new, disconnected from your GitHub account to host this file so as not to expose PII on your regular use GitHub, if you have one, alternately you could make it so your .vcf file does not contain PII but just general information you are willing to remain public and easily accessible.

  1. Go to vCard Maker, fill out all the information you want and download the file.
  2. Create a new gist with whatever name you want and the .vcf extension and copy the contents from your .vcf file into the gist, save as public gist and publish.
  3. Click view RAW gist and copy that URL, if you don't click view raw this won't work Example
  4. Paste that URL as a Custom URI NDEF Record on NFC Tools and write to your tag.
  5. When scanning your tag the, Add Contact preview context window should pop up allowing you to see the information and quickly add it to your contacts.

Note

This does require an internet connection on the receiving phone, if you are in a situation where there is no internet/cell signal the notification can be stashed in the notification centre to be opened later.

Deep Linking with URIs

URI - Uniform Resource Identifiers are a way of specifying the application the data should be handled by given its scheme.

A way to leverage NDEF to suit some use cases better is to utilise URI Schemes, many apps have their own URI schemes which you can google to find out the formatting, this allows you to specify the app you want the information to be passed through instead of opening in the web application version of that app.

Note

Some system functions are exposed over URIs allowing you to navigate specific settings etc by way of calling them over URI.

Worked Example

The user wants a spotify link to open directly in the spotify app instead of opening in the web app for a more seamless experience.

Spotify URL: https://open.spotify.com/track/6k5l8AID6WTHsguJ6rppSI

This has the chance to open in the browser or installed application, to make it open in the spotify app you would encode it like so:

Custom URL/URI

spotify : datatype : ID

Spotify URI: spotify:track:6k5l8AID6WTHsguJ6rppSI

This can be repeated for other data types that aren't direct links to songs, look at the path within the URL and repeat that in the URI following the same format.

Mifare Classic

Mifare Classic has an odd relationship with iOS. You are unable to read/interact with specific chip information such as the UID/ATQA/SAK and memory content from mifare classics using NFC Tools/NXP TagInfo but you are able to use them for Shortcut NFC Automations due to them possessing an ISO14443a UID which is accepted by Shortcuts (this does not use the memory content of a mifare classic and is not related to NDEF, it is simply detecting and parsing the UID), you are unable to see the UID, only being able to give it a custom label.

NDEF on Mifare Classic on iOS

Due to the inability to interact directly with the memory of Mifare Classics on iOS, you're unable to write NDEF records or view NDEF records stored on the tag's memory. You are however, able to use background scanning to pick up and launch stored NDEF records from a mifare classic, provided the record is one of the compatible types listed above.

This means you can use another device such an android to encode a compatible NDEF record onto mifare classic and still have them be detectable with an iPhone.

Smart Posters on iOS

"What is a smart poster?"

Smart posters are descriptive text that can be added to various NDEF record types when using the "NFC TagWriter" app by NXP. Adding a smart poster to a record fundamentally changes that record to be a smart poster record with the original record type and data nested inside of it.

Note

Records with smart posters are unable to be detected by iOS during background reading regardless if the nested record type is compatible with iOS, meaning users will not be prompted to follow the NDEF record wherever it may lead.

iOS is still able to show these records and their info when scanned with an NDEF viewing app like Taginfo or NFCTools.

I would recommend completely ignoring smart posters and not attatching descriptions to your records to prevent breaking compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment