In Cascades, you can
use an NFC Share Card, or use the NFC Share API to send or receive content over NFC.
Alternatively, you can use the C API library (libnfc and
libnfc_bps) to send and receive content.
Some important items to consider when sharing various types of
content:
- You can share any type of content over NFC. However, the size of the
content you share should not exceed 1K. At a transfer speed of no more than 424Kbits
per second, it requires over 40 seconds to transfer 20K of data from one device to
another. During this transfer time, the devices have to be held together. Further,
most NFC tags can hold no more than a few hundred bytes of data, except for the most
expensive ones, which can hold 1K or 4K of data.
- File sharing over NFC uses Bluetooth or Wi-Fi connection
handover. Connection handover over NFC requires no user action; however, the sending
and receiving devices must both support either Bluetooth or Wi-Fi.
- Content cannot be streamed using NFC.
NFC Forum tag reader and writer
A BlackBerry 10 device can read from or write to any tag that the NFC Forum
supports. As a reader, the device detects the tag, reads the NDEF message stored on
the tag, and notifies the interested application for processing. To be able to read
an NDEF message from an NFC tag, an app must register its interest in that type of
message.
An NDEF message may contain multiple records, and an NFC tag may contain two
NDEF messages. In each case, an app is launched according to the following
logic:
- One NDEF message with multiple records: NFC looks for an
application registered for the first record type. If it is found, the app is
notified and handles the message. If no app is registered to handle the first
record, NFC continues on to the next record. For example, an NDEF message may
contain two records: a proprietary Type Name Format (TNF) for the first record
and a link to the BlackBerry World
storefront for the second record. The link to the BlackBerry World
storefront allows users to download the app.
- Two NDEF messages with one record each: NFC acts on both messages
simultaneously. An example use case is:
- The first NDEF message contains credentials for setting up a
Bluetooth connection and is dispatched to an app to
establish a connection with a Bluetooth
headset.
- The second NDEF message is dispatched to a separate handler,
which responds by launching an app to play music
using the Bluetooth connection.
Supported NFC tags
The BlackBerry 10 devices support the following NFC Forum compliant tags:
| NFC Forum tag type |
Supported tags |
| Type 1 |
|
| Type 2 |
- MiFare Ultra Light
- MiFare Ultra Light C
- Infineon my-D Move
- Infineon my-D NFC
- Kovio 2K
- NTAG203
|
| Type 3 |
- FeliCa RC-S888
- FeliCa RC-S965
- FeliCa Lite-S RC-S966
|
| Type 4 |
- MiFare DESFire EV1 (2k, 4k, 8k)
- MicroPass 4101-2K
MiFare DESFire EV1 tags must be pre-formatted before they
can be used with a BlackBerry 10 device. |
ISO 15693 tag reader and writer
The BlackBerry 10
device can also read and write to ISO 15693 tags.
To read an ISO 15693 tag, register for tag detection events by calling
nfc_register_tag_readerwriter(TAG_TYPE_ISO_15693_3).
To write to an ISO 15693 tag, use nfc_tag_transceive().
Working with the mimeType,
uri, and data
properties
If you want to use Cascades to share an NDEF message, set the MIME-type of that content to
application/vnd.rim.nfc.ndef. The mimeType, uri, and
data properties are exposed in the following
way:
- If you want to share content using an NFC Share Card and QML,
define the mimeType, uri, and data properties in the
query element of the InvokeActionItem.
- If you want to share content using an NFC Share Card and C++,
define the mimeType, uri, and data properties in the
InvokeRequest.
- If you use the NFC Share API instead of an NFC Share Card to
share content, define the mimeType, uri, and data
properties either in an instance of the
NfcShareDataContent class (when sharing
data), or in an instance of the
NfcShareFilesContentclass (when sharing
files), and then pass the instance to the
NfcShareManager::setShareContent()
function.
Working with the NFC C API
If you want to use the NFC service C API (libnfc and
libnfc_bps) to send or receive content, you must first connect
to the NFC system and then register with the NFC service for the types of NFC events
you are interested in. Failure to connect to the NFC system will result in the
NFC_RESULT_SERVICE_CONNECTION_ERROR.
You can connect to the NFC system in one of the following two ways:
- Connecting directly using nfc_connect(). You
can read NFC events using nfc_read_event().
- Registering with the BlackBerry Platform Services (BPS) using nfc_request_events(). The
libnfc_bps library manages the NFC connection for your
app and delivers NFC events to the app.
To register for NFC events, you call API functions defined in
nfc.h.
For example:
- To read or write to an NFC tag, register for tag detection events using
nfc_register_tag_readerwriter() and pass in the
particular type of tag (defined in nfc_tag_type_t) your app
is interested in as a parameter.
- To be notified of LLCP connections from another NFC device, register this
interest using nfc_register_snep_client().
- To send a large file using Bluetooth
or Wi-Fi
connection handover, register to receive handover events using
nfc_register_handover_listener(). Handover events are
defined in nfc_event_type_t.