This is an archived page. It's not actively maintained.


The getNFCTag() method of the MozNFC interface returns an NDEF tag interface (MozNFCTag object) used to interact with NFC Tags.

It currently only supports NFC Data Exchange Format (NDEF) compatible NFC tag types, but its functionality will be expanded soon.


MozNFCTag getNFCTag(DOMString sessionId);


This example gives an idea of how you can set your activity handler function, then receive a session token from the activity when the function runs and get the NFC tag by passing it to getNFCTag():

navigator.mozSetMessageHandler('activity', ndefDiscoveredHandler);

function ndefDiscoveredHandler(activity) {
  var data =;
  var tag = navigator.mozNfc.getNFCTag(data.sessionToken);
  console.log(tag instanceof MozNFCTag); // should print true


sessionToken: The session token associates the web application with the NFC hardware. It's found in the incoming Web Activity's data.sessionToken property, as seen in the above example.


A MozNFCTag object.


If an invalid session token is passed to getNFCTag(), it throws the error "Unable to create NFCTag object, Reason:  Bad SessionToken".


The NFC implementation in Gecko follows the NFC Forum specifications.

Browser compatibility

Supported in Firefox OS 2.0 for certified-apps.
Available in privileged apps as of Firefox OS 2.2.

See also