Mobile Web Wearable Web

NFC

Near Field Communication (NFC) service enables information exchange between NFC-enabled devices (called "peers") or tags. The NFC-enabled devices can share contacts, photos, and videos, and can also act as smart cards. You can use an NFC-enabled device to communicate with NFC tags for a variety of activities, such as paying the grocery bill or downloading a coupon.

The NFC API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices. The NFC API is not supported on any Tizen Emulators.

NFC provides the following advantages over short-range communication technologies, such as Bluetooth:

  • Faster set-up
  • Lower power consumption
  • No device pairing requirements
  • Reduction in unwanted interruptions

An NFC tag is a chip which can securely store personal information, such as debit card numbers or contact details. The methods of the NFCTag interface (in mobile and wearable applications) are used to access an NFC tag for reading or writing information. NFC tag types are identified using the type attribute of the NFCTagType type definition (in mobile and wearable applications).

Note
Tizen provides the following NFC tag types: GENERIC_TARGET, ISO14443_A, ISO14443_4A, ISO14443_3A, MIFARE_MINI, MIFARE_1K, MIFARE_4K, MIFARE_ULTRA, MIFARE_DESFIRE, ISO14443_B, ISO14443_4B, ISO14443_BPRIME, FELICA, JEWEL, ISO15693, and UNKNOWN_TARGET.

The NFC forum defines the NFC data exchange format (NDEF) for encapsulating the data exchanged between 2 NFC-enabled devices or an NFC-enabled device and an NFC tag. An NDEF message can store data in various formats, such as text, Multipurpose Internet Mail Extension (MIME) type object, or ultra-short RagTime Document (RTD). The NFC tags use NDEF for exchanging messages.

The main features of the NFC API include:

  • NFC device management

    You can manage NFC connectivity by enabling or disabling the NFC service.

    To use NFC, retrieve the default NFC adapter using the getDefaultAdapter() method of the NFCAdapter interface (in mobile and wearable applications). You can enable and disable NFC using the setPowered() method.

  • NFC tag and peer detection

    To receive notifications when an NFC tag or peer device has been detected, the setTagListener() and setPeerListener() methods of the NFCAdapter interface register event listeners, which trigger notifications when an NFC tag or peer device is detected, respectively. You can use the NFCTagDetectCallback (in mobile and wearable applications) and NFCPeerDetectCallback (in mobile and wearable applications) interfaces to define event handlers for receiving the notifications about attaching and detaching NFC tags and peers, respectively.

  • NDEF message manipulation

    You can handle NDEF messages by first creating NDEF records, using the NDEFRecord interface (in mobile and wearable applications), and then adding the records to an NDEF message using the records attribute of the NDEFMessage interface (in mobile and wearable applications).

  • NDEF data exchange

    You can exchange NDEF data between tags and peers. To exchange data between tags, read from tags and write to tags using the readNDEF() and writeNDEF() methods.

    To exchange data between peers, the setReceiveNDEFListener() method of the NFCPeer interface (in mobile and wearable applications) registers an event listener, which triggers an event when an NDEF message is received from a peer.

    You can use the NDEFMessageReadCallback interface (in mobile and wearable applications) to define event handlers for reading NDEF messages from tags and peer devices.

  • NFC card emulation

    You can enable NFC card emulation and monitor the secure element transaction taking place using the NFCAdapter interface. The secure element transaction is carried out by the device. The Tizen application can detect the transaction, but does not take part in it. Interpreting the transaction data requires knowledge about the data protocol the transaction uses. With the required knowledge, the application can detect whether the transaction was successful.

  • NFC host-based card emulation (HCE)

    You can handle HCE events and transactions taking place using the NFCAdapter interface. HCE is an on-device technology that permits a phone to perform card emulation on an NFC-enabled device without relying on access to a secure element. The transaction data is routed to the host application directly, instead of routing to a secure element. The Tizen application can detect the transaction and can take part in it.

Note
If an application is on the background and uses the writeNDEF(), transceive(), or sendNDEF() method, an error callback is launched. These methods can only be used in the foreground.

You can launch NFC applications based on the NDEF message content using the application control functionalities. For example, if the application control with the http://tizen.org/appcontrol/operation/nfc/wellknown operation is defined in the config.xml file and an NFC-enabled device reads an NFC tag or receives an NDEF message whose first NDEF record has a record type (tnf value) set as NFC_RECORD_TNF_WELL_KNOWN, the NFC application is launched.

NFC applications can also be launched by the transaction of the card emulation functionality. NFC devices can communicate with point of sales (POS) terminals using the card emulation functionality to, for example, make a payment. If the application control with the http://tizen.org/appcontrol/operation/nfc/transaction operation is defined in the config.xml file and a transaction caused by the card emulation functionality occurs, the NFC application is launched.

The following table lists the NFC operations, scheme and mime.

Table: NFC operations
Operation Scheme MIME
http://tizen.org/appcontrol/operation/nfc/empty NULL NULL
http://tizen.org/appcontrol/operation/nfc/wellknown <scheme>:<host>/<path>

URL, for example:

  • http
  • http://tizen.org/
  • http://tizen.org/about/devices
  • http://tizen.org/about/*

URN, for example:

  • tel
  • mailto
  • mailto:tommy@tizen.org
U/<protocol_code>

For example: U/0x03, U/0x05, U/*

NULL <type_string>/*

For example: T/*, sp/*, */*

http://tizen.org/appcontrol/operation/nfc/mime NULL <type_string>/<subtype_string> (case-insensitive)

For example: text/x-vard, text/*, */*

http://tizen.org/appcontrol/operation/nfc/uri <uri>

For example: http://tizen.org/about/devices

NULL
http://tizen.org/appcontrol/operation/nfc/external <scheme>:<string> (case-insensitive)

For example: nfc:ext.tizen.org.ABC

NULL
http://tizen.org/appcontrol/operation/nfc/transaction nfc://secure/<SE name>/aid/<aid>

For example:

  • nfc://secure/SIM1/aid/123456789
  • nfc://secure/SIM1/aid/1234*
  • nfc://secure/SIM1/aid/*
NULL

* The <protocol_code> and <scheme> must be in sync. See NFCForum-TS-RTD_URI_1.0 and NFC RTD (Record Type Definition) documentation on the NFC forum.

NDEF Messages

Tizen provides the NDEFMessage interface (in mobile and wearable applications) to define an NDEF message. An NDEF message is composed of multiple records.

An NDEF record is created using the NDEFRecord interface (in mobile and wearable applications) and is identified by record type, ID, and payload.

The following figure shows the conceptual structure of an NDEF message.

Figure: Structure of an NDEF message

Structure of an NDEF message

A record in an NDEF message can be created by using the following payload types:

  • Text

    The NDEF record content is created using text format.

    The NDEFRecordText interface (in mobile and wearable applications) is used to create the text format payload using the text, languageCode, and encoding attributes.

  • URI

    The NDEF record content is created using a URI.

    The NDEFRecordURI interface (in mobile and wearable applications) is used to create the URI type payload using the uri attribute.

  • Media

    The NDEF record content is created using a media format.

    The NDEFRecordMedia interface (in mobile and wearable applications) is used to create the media format payload using the mimeType attribute.

Go to top