ti.nfc
Read Android NFC sensors with the Titanium SDK.
API reference
Modules.Nfc
Extends Titanium.Module
A cross-platform Near-Field-Communication (NFC) module for iOS and Android. Download the latest release via Github.
This module provides access to Near Field Communication (NFC) functionality, allowing applications to read and write (Android-only) NFC tags. A "tag" may actually be another device that appears as a tag.
NFC Resources
- Android
- iOS
Requirements
-
Android
- Android 4.1 (API 16) and later
- An NFC capable device
-
iOS
- iOS 11 and later
- iPhone 7 / iPhone 7 Plus and later
Getting Started
- View the Using Titanium Modules document for instructions on getting started with using this module in your application.
Configure iOS: Capabilities and Provisioning Profiles
-
Required capabilities:
<key>com.apple.developer.nfc.readersession.formats</key> <array> [string](api:Global.String)NDEF</string> </array> -
Provisioning Profile entitled with the NFC Tag Reading capability
Configure Android: Tag Dispatching and Intent Filters
-
The Android tag dispatch system is responsible for dispatching NFC messages to the appropriate application. In the situation where you are not using foreground dispatching, you will need to define intent-filters in the tiapp.xml file to specify which types of NFC messages the application wants to receive. By using intent-filters in the tiapp.xml file, the application will be automatically started if a matching NFC message is dispatched.
Add code similar to the following to your tiapp.xml file:
-
Replace occurrences of the activity name (
Tagviewer) with your activity name. -
Add the NFC permissions to your Android configuration
-
Replace the NFC specific intent filters with filters appropriate for your application.
<android xmlns:android="http://schemas.android.com/apk/res/android"> <manifest> <!-- Required NFC permissions --> <uses-permission android:name="android.permission.NFC" /> <uses-feature android:name="android.hardware.nfc" android:required="true" /> <!-- NFC Intent filters --> <application> <activity android:name=".TagviewerActivity" android:label="TagViewer" android:theme="@style/Theme.Titanium" android:configChanges="keyboardHidden|orientation" android:exported="true"> <intent-filter> <action android:name="android.nfc.action.TECH_DISCOVERED"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> <intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED"/> <category android:name="android.intent.category.DEFAULT"/> <data android:mimeType="text/plain" /> </intent-filter> <intent-filter> <action android:name="android.nfc.action.TAG_DISCOVERED"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> </application> </manifest> </android>
Note that if you are using foreground dispatching you do not need to define intent filters in the application's tiapp.xml file.
-
Accessing the Module
-
Use
requireto access this module from JavaScript:var nfc = require('ti.nfc');The
nfcvariable is a reference to the Module object.
Creating an Adapter
-
The NFC adapter gives you access to the features of the NFC device. The NFC adapter proxy is always associated with the activity that was the current activity when it was created. Therefore, the NFC Adapter should be created after the activity has been opened. You can use the window
openevent to know when the activity has been opened.$.index.addEventListener('open', function(e) { nfcAdapter = nfc.createNfcAdapter({ onNdefDiscovered: handleDiscovery, onTagDiscovered: handleDiscovery, // Android-only onTechDiscovered: handleDiscovery // Android-only }); if (!nfcAdapter.isEnabled()) { Ti.API.error('NFC is not enabled on this device!'); return; } });
Handling Intents (Android)
-
NFC Intents are dispatched to an activity by the Android tag dispatch system. When your activity receives a new intent, it must forward the intent to the
onNewIntentmethod of the NFC adapter for processing.Ti.Android.currentActivity.addEventListener('newintent', function (e) { nfcAdapter.onNewIntent(e.intent); });If your application is started as the result of an NFC intent, that intent will automatically be processed when the NFC module is loaded.
Foreground Dispatch
-
The foreground dispatch system allows an activity to intercept an intent and claim priority over other activities that handle the same intent. When using foreground dispatching, you must process the
pauseandresumeevents on the activity and enable or disable foreground dispatching.var currentActivity = Ti.Android.currentActivity; currentActivity.addEventListener('resume', function(e) { nfcAdapter.enableForegroundDispatch(dispatchFilter); }); currentActivity.addEventListener('pause', function(e) { nfcAdapter.disableForegroundDispatch(); });
Example applications
-
Android example applications are located in the
example/androidfolder of the module:TagBeamdemonstrates how to use Android Beam to send messages to another NFC capable device.TagForegrounddemonstrates how to read NFC tags only when the application is in the foreground.TagViewerdemonstrates how to receive NFC tag intents even when the application is not running.TagWriterdemonstrates how to write to an NFC tag using the Ndef tag technology data format.
-
iOS example applications are located in the
example/iosfolder of the module:TagViewerdemonstrates how to receive NFC tags even when the application is running.
Examples
Creating NFC Adapter (iOS & Android)
This example demonstrates the proper technique for creating an NFC adapter. The NFC Adapter should be created after the window has been opened.
var nfc = require('ti.nfc');
var nfcAdapter = null;
$.index.addEventListener('open', function(e) {
// Must wait until the activity has been opened before setting up NFC
// Create the NFC adapter to be associated with this activity.
// There should only be ONE adapter created per activity.
nfcAdapter = nfc.createNfcAdapter({
onNdefDiscovered: handleDiscovery,
onTagDiscovered: handleDiscovery, // Android-only
onTechDiscovered: handleDiscovery // Android-only
});
// It's possible that the device does not support NFC. Check it here
// before we go any further. For iOS, right now this is decided
// internally by the system.
if (OS_ANDROID) {
if (!nfcAdapter.isEnabled()) {
alert('NFC is not enabled on this device');
return;
}
Ti.Android.currentActivity.addEventListener('newintent', function (e) {
nfcAdapter.onNewIntent(e.intent);
});
// iOS needs to be told to scan
} else if (OS_IOS) {
nfcAdapter.begin();
}
});
function handleDiscovery(e) {
alert(JSON.stringify(e, null, 2));
}
$.index.open();
Properties 61
Intent to start an activity when a tag with NDEF payload is discovered.
Intent to start an activity when a tag is discovered.
Intent to start an activity when a tag is discovered and activities are registered for the specific technologies on the tag.
The tag has been configured with invalid parameters.
Used with ndefRecord records.
Indicates UTF-16 text encoding.
Used with ndefRecord records.
Indicates UTF-8 text encoding.
A security violation associated with the reader session has occurred.
The reader session does not support this feature.
The first NDEF tag read by this session is invalid.
The reader session terminated unexpectedly.
The reader session timed out.
The reader session failed because the system is busy.
The user canceled the reader session.
Used with TECH_MIFARE_CLASSIC tag technology. Size of a MIFARE CLassic block (in bytes).
Used with TECH_MIFARE_CLASSIC tag technology. Tag contains 16 sectors, each with 4 blocks.
Used with TECH_MIFARE_CLASSIC tag technology. Tag contains 32 sectors, each with 4 blocks.
Used with TECH_MIFARE_CLASSIC tag technology. Tag contains 40 sectors.
Used with TECH_MIFARE_CLASSIC tag technology. Tag contains 5 sectors, each with 4 blocks.
Used with TECH_MIFARE_CLASSIC tag technology. A MIFARE Classic tag.
Used with TECH_MIFARE_CLASSIC tag technology. A MIFARE Plus tag.
Used with TECH_MIFARE_CLASSIC tag technology. A MIFARE Pro tag.
Used with TECH_MIFARE_CLASSIC tag technology. A MIFARE Classic compatible card of unknown type.
Used with TECH_MIFARE_ULTRALIGHT tag technology. Size of a MIFARE Ultralight page (in bytes).
Used with TECH_MIFARE_ULTRALIGHT tag technology. A MIFARE Ultralight tag.
Used with TECH_MIFARE_ULTRALIGHT tag technology. A MIFARE Ultralight C tag.
Used with TECH_MIFARE_ULTRALIGHT tag technology. A MIFARE Ultralight compatible tag of unknown type.
Used with NdefSmartPoster records (RTD_SMART_POSTER).
Used with NdefSmartPoster records (RTD_SMART_POSTER).
Used with NdefSmartPoster records (RTD_SMART_POSTER).
Used with NdefSmartPoster records (RTD_SMART_POSTER).
Used with ndefRecord records.
RTD Alternative Carrier type. For use with TNF_WELL_KNOWN.
Used with ndefRecord records.
RTD Handover Carrier type. For use with TNF_WELL_KNOWN.
Used with ndefRecord records.
RTD Handover Request type. For use with TNF_WELL_KNOWN.
Used with ndefRecord records.
RTD Handover Select type. For use with TNF_WELL_KNOWN.
Used with ndefRecord records.
RTD Smart Poster type. For use with TNF_WELL_KNOWN.
Used with ndefRecord records.
RTD Text type. For use with TNF_WELL_KNOWN.
Used with ndefRecord records.
RTD URI type. For use with TNF_WELL_KNOWN.
Used with TECH_NDEF tag technology. NDEF on MIFARE Classic.
Used with TECH_NDEF tag technology. NFC Forum Tag Type 1.
Used with TECH_NDEF tag technology. NFC Forum Tag Type 2.
Used with TECH_NDEF tag technology. NFC Forum Tag Type 3.
Used with TECH_NDEF tag technology. NFC Forum Tag Type 4.
Available tag technology used with getTechList and AdapterProxy.
Available tag technology used with getTechList and AdapterProxy.
Available tag technology used with getTechList and AdapterProxy.
Available tag technology used with getTechList and AdapterProxy.
Available tag technology used with getTechList and AdapterProxy.
Available tag technology used with getTechList and AdapterProxy.
Available tag technology used with getTechList and AdapterProxy.
Available tag technology used with getTechList and AdapterProxy.
Available tag technology used with getTechList and AdapterProxy.
Used with ndefRecord records. Indicates the type field contains an absolute-URI BNF construct defined by RFC 3986.
Used with ndefRecord records. Indicates the record is empty.
Used with ndefRecord records. Indicates the type field contains an external type name.
Used with ndefRecord records.
Indicates the type field contains a media-type BNF construct, defined by RFC 2046.
Used with ndefRecord records.
Indicates the payload is an intermediate or final chunk of a chunked NDEF Record.
Used with ndefRecord records.
Indicates the payload type is unknown.
Used with ndefRecord records.
Indicates the type field contains a well-known RTD type name.
Too many retries have occurred.
Connection to the tag has been lost.
The tag has responded with an error.
Methods 22
Creates and returns an instance of Modules.Nfc.MifareTagTechnology.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.MifareTagTechnology> | Properties to set on a new object, including any defined by Modules.Nfc.MifareTagTechnology except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.NativeTagTechnology.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.NativeTagTechnology> | Properties to set on a new object, including any defined by Modules.Nfc.NativeTagTechnology except those marked not-creation or read-only. |
createNdefMessage
since Android 1.0.0, iPhone 6.3.0Creates and returns an instance of Modules.Nfc.NdefMessage.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.NdefMessage> | Properties to set on a new object, including any defined by Modules.Nfc.NdefMessage except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.NdefRecordApplication.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.NdefRecordApplication> | Properties to set on a new object, including any defined by Modules.Nfc.NdefRecordApplication except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.NdefRecordEmpty.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.NdefRecordEmpty> | Properties to set on a new object, including any defined by Modules.Nfc.NdefRecordEmpty except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.NdefRecordExternal.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.NdefRecordExternal> | Properties to set on a new object, including any defined by Modules.Nfc.NdefRecordExternal except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.NdefRecordMedia.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.NdefRecordMedia> | Properties to set on a new object, including any defined by Modules.Nfc.NdefRecordMedia except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.NdefRecordSmartPoster.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.NdefRecordSmartPoster> | Properties to set on a new object, including any defined by Modules.Nfc.NdefRecordSmartPoster except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.NdefRecordText.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.NdefRecordText> | Properties to set on a new object, including any defined by Modules.Nfc.NdefRecordText except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.NdefRecordUnknown.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.NdefRecordUnknown> | Properties to set on a new object, including any defined by Modules.Nfc.NdefRecordUnknown except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.NdefRecordUri.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.NdefRecordUri> | Properties to set on a new object, including any defined by Modules.Nfc.NdefRecordUri except those marked not-creation or read-only. |
createNfcAdapter
since 1.0.0Creates and returns an instance of Modules.Nfc.NfcAdapter.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.NfcAdapter> | Properties to set on a new object, including any defined by Modules.Nfc.NfcAdapter except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.NfcForegroundDispatchFilter.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.NfcForegroundDispatchFilter> | Properties to set on a new object, including any defined by Modules.Nfc.NfcForegroundDispatchFilter except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.TagTechnologyIsoDep.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.TagTechnologyIsoDep> | Properties to set on a new object, including any defined by Modules.Nfc.TagTechnologyIsoDep except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.TagTechnologyMifareClassic.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.TagTechnologyMifareClassic> | Properties to set on a new object, including any defined by Modules.Nfc.TagTechnologyMifareClassic except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.TagTechnologyMifareUltralight.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.TagTechnologyMifareUltralight> | Properties to set on a new object, including any defined by Modules.Nfc.TagTechnologyMifareUltralight except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.TagTechnologyNdef.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.TagTechnologyNdef> | Properties to set on a new object, including any defined by Modules.Nfc.TagTechnologyNdef except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.TagTechnologyNdefFormatable.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.TagTechnologyNdefFormatable> | Properties to set on a new object, including any defined by Modules.Nfc.TagTechnologyNdefFormatable except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.TagTechnologyNfcA.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.TagTechnologyNfcA> | Properties to set on a new object, including any defined by Modules.Nfc.TagTechnologyNfcA except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.TagTechnologyNfcB.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.TagTechnologyNfcB> | Properties to set on a new object, including any defined by Modules.Nfc.TagTechnologyNfcB except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.TagTechnologyNfcF.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.TagTechnologyNfcF> | Properties to set on a new object, including any defined by Modules.Nfc.TagTechnologyNfcF except those marked not-creation or read-only. |
Creates and returns an instance of Modules.Nfc.TagTechnologyNfcV.
| Parameters | Type | Description |
|---|---|---|
| parameters? | Dictionary<Modules.Nfc.TagTechnologyNfcV> | Properties to set on a new object, including any defined by Modules.Nfc.TagTechnologyNfcV except those marked not-creation or read-only. |
Modules.Nfc.MifareTagTechnology
Extends Modules.Nfc.NativeTagTechnologyTitanium.Proxy
Provides access to MIFARE Ultralight properties and I/O operations on a Modules.Nfc.NfcTag.
Use the Modules.Nfc.createTagTechnologyMifareUltralight method to create this tag technology. See also: Mifare Ultralight
Methods 7
Inherited from Modules.Nfc.NativeTagTechnology
calls the connected to tag method for NFC Tag reader session.
The historical bytes extracted from an Answer To Select response.
The unique hardware identifier of the tag.
Inherited from Modules.Nfc.NativeTagTechnology
if session is connected to any tag or not
provides if session is connected
The MIFARE product family identifier for the tag.
Sends a native MIFARE command to the tag.
| Parameters | Type | Description |
|---|---|---|
| data | Array<Number> | hex command with length will be sent in form of data |
| errorCode | String | The error code; only present if an error occurred. |
| errorDomain | String | The error domain; only present if an error occurred. |
| errorDescription | String | The error description; only peresent if an error occurred. |
Sends a native MIFARE command to the tag along with other parameter.
| Parameters | Type | Description |
|---|---|---|
| data | Array<Number> | hex command with length will be sent in form of data |
| sw1 | Number | The SW1 command-processing status byte. |
| sw2 | Number | The SW2 command-processing status byte. |
| apdu | Titanium.Buffer | An ISO 7816-4 command APDU object. |
| errorCode | String | The error code; only present if an error occurred. |
| errorDomain | String | The error domain; only present if an error occurred. |
| errorDescription | String | The error description; only peresent if an error occurred. |
Modules.Nfc.NativeTagTechnology
Extends Titanium.Proxy
Native Tag Technology class will have the common methods.
Common methods get called for all the native tags so that we can save the redundancy of the code.
Methods 2
calls the connected to tag method for NFC Tag reader session.
if session is connected to any tag or not
provides if session is connected
Modules.Nfc.NdefMessage
Extends Titanium.Proxy
Represents an immutable NDEF message.
Use the Modules.Nfc.createNdefMessage method to create an NDEF message.
See also: NdefMessage
Properties 1
NDEF records inside this NDEF message.
Methods 1
toByte
AndroidReturn the NDEF message as raw bytes.
Modules.Nfc.NdefRecord
Extends Titanium.Proxy
Represents an immutable NDEF record.
Android: The NDEF record is the base type for more type-specific NDEF records. You will generally work with the type-specific NDEF records (e.g. NdefRecordText, NdefRecordUri, etc.) which have more applicable properties for each type of record.
Use one of the Modules.Nfc.createNdefRecordApplication, Modules.Nfc.createNdefRecordEmpty, Modules.Nfc.createNdefRecordExternal, Modules.Nfc.createNdefRecordMedia, Modules.Nfc.createNdefRecordSmartPoster, Modules.Nfc.createNdefRecordText, Modules.Nfc.createNdefRecordUnknown, or Modules.Nfc.createNdefRecordUri method variants to create an NDEF record.
iOS: The NFC-functionality is available on iOS 11 and later. It currently only allows to read specific NDEF-tags - writing tags is not supported by iOS so far.
See also: NdefRecord
Properties 6
The integer hash code for this object.
The variable length ID.
The variable length payload for the record.
The record type.
The 3-bit TNF.
The variable length Type field.
Methods 5
getHashCode
AndroidReturns the integer hash code for this object.
Returns the variable length ID.
getRecordType
AndroidReturns the record type.
This is the class name of the NDEF record (e.g. NdefRecordText)
Returns the 3-bit TNF.
Returns the variable length Type field.
Modules.Nfc.NdefRecordApplication
Extends Modules.Nfc.NdefRecordTitanium.Proxy
Represents an immutable NDEF record indicating the package that should be used to handle the entire NDEF message.
This record type was introduced in Android 4.0 (API level 14).
See also: createApplicationRecord
Properties 7
Inherited from Modules.Nfc.NdefRecord
The integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
The variable length ID.
packageName
StringApplication package name.
Inherited from Modules.Nfc.NdefRecord
The variable length payload for the record.
Inherited from Modules.Nfc.NdefRecord
The record type.
Inherited from Modules.Nfc.NdefRecord
The 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
The variable length Type field.
Methods 5
Inherited from Modules.Nfc.NdefRecord
Returns the integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length ID.
Inherited from Modules.Nfc.NdefRecord
Returns the record type.
Inherited from Modules.Nfc.NdefRecord
Returns the 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length Type field.
Modules.Nfc.NdefRecordEmpty
Extends Modules.Nfc.NdefRecordTitanium.Proxy
Represents an immutable NDEF record that is empty.
Properties 6
Inherited from Modules.Nfc.NdefRecord
The integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
The variable length ID.
Inherited from Modules.Nfc.NdefRecord
The variable length payload for the record.
Inherited from Modules.Nfc.NdefRecord
The record type.
Inherited from Modules.Nfc.NdefRecord
The 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
The variable length Type field.
Methods 5
Inherited from Modules.Nfc.NdefRecord
Returns the integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length ID.
Inherited from Modules.Nfc.NdefRecord
Returns the record type.
Inherited from Modules.Nfc.NdefRecord
Returns the 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length Type field.
Modules.Nfc.NdefRecordExternal
Extends Modules.Nfc.NdefRecordTitanium.Proxy
Represents an immutable NDEF record containing external (application-specific) data.
See also: createExternal
Properties 8
domain
StringDomain name of issuing organization.
domainType
StringDomain-specific type of data.
Inherited from Modules.Nfc.NdefRecord
The integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
The variable length ID.
Inherited from Modules.Nfc.NdefRecord
The variable length payload for the record.
Inherited from Modules.Nfc.NdefRecord
The record type.
Inherited from Modules.Nfc.NdefRecord
The 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
The variable length Type field.
Methods 5
Inherited from Modules.Nfc.NdefRecord
Returns the integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length ID.
Inherited from Modules.Nfc.NdefRecord
Returns the record type.
Inherited from Modules.Nfc.NdefRecord
Returns the 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length Type field.
Modules.Nfc.NdefRecordMedia
Extends Modules.Nfc.NdefRecordTitanium.Proxy
Represents an immutable NDEF record containing MIME data.
See also: createMime
Properties 7
Inherited from Modules.Nfc.NdefRecord
The integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
The variable length ID.
mimeType
StringA valid MIME type.
Inherited from Modules.Nfc.NdefRecord
The variable length payload for the record.
Inherited from Modules.Nfc.NdefRecord
The record type.
Inherited from Modules.Nfc.NdefRecord
The 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
The variable length Type field.
Methods 5
Inherited from Modules.Nfc.NdefRecord
Returns the integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length ID.
Inherited from Modules.Nfc.NdefRecord
Returns the record type.
Inherited from Modules.Nfc.NdefRecord
Returns the 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length Type field.
Modules.Nfc.NdefRecordSmartPoster
Extends Modules.Nfc.NdefRecordTitanium.Proxy
Represents an immutable NDEF record containing a Smart Poster message.
Properties 10
action
NumberRecommended action.
Inherited from Modules.Nfc.NdefRecord
The integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
The variable length ID.
mimeType
StringA valid MIME type for the external resource.
Inherited from Modules.Nfc.NdefRecord
The variable length payload for the record.
Inherited from Modules.Nfc.NdefRecord
The record type.
title
StringTitle for the Smart Poster.
Inherited from Modules.Nfc.NdefRecord
The 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
The variable length Type field.
uri
StringUri for the external resource.
Methods 5
Inherited from Modules.Nfc.NdefRecord
Returns the integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length ID.
Inherited from Modules.Nfc.NdefRecord
Returns the record type.
Inherited from Modules.Nfc.NdefRecord
Returns the 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length Type field.
Modules.Nfc.NdefRecordText
Extends Modules.Nfc.NdefRecordTitanium.Proxy
Represents an immutable NDEF record containing text.
Properties 9
encoding
StringEncoding format. Default is ENCODING_UTF8 ("UTF-8");
Inherited from Modules.Nfc.NdefRecord
The integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
The variable length ID.
languageCode
StringLanguage code. Defaults to current locale.
Inherited from Modules.Nfc.NdefRecord
The variable length payload for the record.
Inherited from Modules.Nfc.NdefRecord
The record type.
text
StringText.
Inherited from Modules.Nfc.NdefRecord
The 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
The variable length Type field.
Methods 5
Inherited from Modules.Nfc.NdefRecord
Returns the integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length ID.
Inherited from Modules.Nfc.NdefRecord
Returns the record type.
Inherited from Modules.Nfc.NdefRecord
Returns the 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length Type field.
Modules.Nfc.NdefRecordUnknown
Extends Modules.Nfc.NdefRecordTitanium.Proxy
Represents an immutable NDEF record containing an unknown data format.
Properties 6
Inherited from Modules.Nfc.NdefRecord
The integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
The variable length ID.
Inherited from Modules.Nfc.NdefRecord
The variable length payload for the record.
Inherited from Modules.Nfc.NdefRecord
The record type.
Inherited from Modules.Nfc.NdefRecord
The 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
The variable length Type field.
Methods 5
Inherited from Modules.Nfc.NdefRecord
Returns the integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length ID.
Inherited from Modules.Nfc.NdefRecord
Returns the record type.
Inherited from Modules.Nfc.NdefRecord
Returns the 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length Type field.
Modules.Nfc.NdefRecordUri
Extends Modules.Nfc.NdefRecordTitanium.Proxy
Represents an immutable NDEF record containing a URI.
See also: createUri
Properties 7
Inherited from Modules.Nfc.NdefRecord
The integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
The variable length ID.
Inherited from Modules.Nfc.NdefRecord
The variable length payload for the record.
Inherited from Modules.Nfc.NdefRecord
The record type.
Inherited from Modules.Nfc.NdefRecord
The 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
The variable length Type field.
uri
StringURI or URL.
Methods 5
Inherited from Modules.Nfc.NdefRecord
Returns the integer hash code for this object.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length ID.
Inherited from Modules.Nfc.NdefRecord
Returns the record type.
Inherited from Modules.Nfc.NdefRecord
Returns the 3-bit TNF.
Inherited from Modules.Nfc.NdefRecord
Returns the variable length Type field.
Modules.Nfc.NfcAdapter
Extends Titanium.Proxy
Represents the local NFC adapter.
The NFC adapter gives you access to the features of the NFC device. The NFC adapter proxy is always
associated with the activity that was the current activity when it was created. The NFC Adapter must
be created after the activity has been opened. You can use the window open event to know when the
activity has been opened.
Use the Modules.Nfc.createNfcAdapter method to create an NFC adapter.
See also: NfcAdapter
Examples
Foreground Dispatch (Android)
This example uses foreground dispatch to receive NDEF messages only when the application is in the foreground.
// Create the NFC adapter to be associated with this activity.
// There should only be ONE adapter created per activity.
nfcAdapter = nfc.createNfcAdapter({
onNdefDiscovered: handleDiscovery,
onTagDiscovered: handleDiscovery,
onTechDiscovered: handleDiscovery
});
// It's possible that the device does not support NFC. Check it here
// before we go any further.
if (!nfcAdapter.isEnabled()) {
alert('NFC is not enabled on this device');
return;
}
// All tag scans are received by the activity as a new intent. Each
// scan intent needs to be passed to the nfc adapter for processing.
var act = Ti.Android.currentActivity;
act.addEventListener('newintent', function(e) {
nfcAdapter.onNewIntent(e.intent);
});
// To enable NFC dispatching only while the application is in the foreground,
// the application must signal the module whenever the application state changes.
act.addEventListener('resume', function(e) {
nfcAdapter.enableForegroundDispatch(dispatchFilter);
});
act.addEventListener('pause', function(e) {
nfcAdapter.disableForegroundDispatch();
});
// This application is only interested in receiving NFC messages while
// in the foreground. So the dispatch filter must be defined to identify
// what types of NFC messages to receive.
dispatchFilter = nfc.createNfcForegroundDispatchFilter({
intentFilters: [
{ action: nfc.ACTION_NDEF_DISCOVERED, mimeType: 'text/plain' },
{ action: nfc.ACTION_NDEF_DISCOVERED, scheme: 'http', host: 'www.appcelerator.com' }
],
techLists: [
[ "android.nfc.tech.NfcF" ],
[ "android.nfc.tech.Ndef" ],
[ "android.nfc.tech.MifareClassic" ],
[ "android.nfc.tech.NfcA" ]
]
});
Push Message (Android)
This example sets a default push message to send using Android Beam.
// Create the NFC adapter to be associated with this activity.
// There should only be ONE adapter created per activity.
nfcAdapter = nfc.createNfcAdapter({});
// It's possible that the device does not support NFC. Check it here
// before we go any further.
if (!nfcAdapter.isNdefPushEnabled()) {
alert('NFC is not enabled on this device');
return;
}
// Set the default Ndef message to send when tapped
var textRecord = nfc.createNdefRecordText({
text: "NDEF Push Sample"
});
var msg = nfc.createNdefMessage({
records: [ textRecord ]
});
nfcAdapter.setNdefPushMessage(msg);
Push Message Callback (Android)
This example uses the push message callback to dynamically create the NDEF message as needed.
// Create the NFC adapter to be associated with this activity.
// There should only be ONE adapter created per activity.
nfcAdapter = nfc.createNfcAdapter({
onPushMessage: function() {
if (sendText) {
ndefRecord = nfc.createNdefRecordText({
text: "Hello"
});
} else {
ndefRecord = nfc.createNdefRecordUri({
uri: "http://www.appcelerator.com"
});
}
return nfc.createNdefMessage({
records: [
ndefRecord
]
});
}
});
// It's possible that the device does not support NFC. Check it here
// before we go any further.
if (!nfcAdapter.isEnabled()) {
alert('NFC is not enabled on this device');
return;
}
Properties 8
Session will automatically invalidate after the first NDEF tag is read
successfully when this is set to true, and the error callback will
return Modules.Nfc.INVALIDATION_ERROR_FIRST_NDEF_TAG_READ in this case.
Callback function used to dynamically generate one or more Uris to send using Android Beam.
The callback function must return an array of Uri(s) to be pushed. This method is only available on Android 4.0 (API 16) and above.
See also: [setBeamPushUrisCallback](http://developer.android.com/reference/android/nfc/NfcAdapter.html#setBeamPushUrisCallback(android.nfc.NfcAdapter.CreateBeamUrisCallback, android.app.Activity))
Callback function to execute when a tag with NDEF payload is discovered.
See also: ACTION_NDEF_DISCOVERED
Callback function to execute when a session was invalidated (either errored by the system or cancelled by the user).
Callback function to execute on successful Android Beam operation.
This method is only available on Android 4.0 (API 14) and above.
See also: [setOnNdefPushCompleteCallback](http://developer.android.com/reference/android/nfc/NfcAdapter.html#setOnNdefPushCompleteCallback(android.nfc.NfcAdapter.OnNdefPushCompleteCallback, android.app.Activity, android.app.Activity...)) in the Android Developer Reference.
Callback function used to dynamically generated NDEF messsages to send using Android Beam.
The callback function must return an NDEF message to be used for the Android Beam operation. This method is only available on Android 4.0 (API 14) and above.
See also: [setNdefPushMessageCallback](http://developer.android.com/reference/android/nfc/NfcAdapter.html#setNdefPushMessageCallback(android.nfc.NfcAdapter.CreateNdefMessageCallback, android.app.Activity, android.app.Activity...)) in the Android Developer Reference.
Callback function to execute when a tag is discovered.
See also: ACTION_TAG_DISCOVERED
Callback function to execute when a tag is discovered and activities are registered for the specific technologies on the tag.
See also: ACTION_TECH_DISCOVERED
Methods 11
Disable foreground dispatch to the current activity.
Disable NDEF message push over P2P.
This method was deprecated in API level 14. Use setNdefPushMessage instead.
Disable reader mode in the current activity.
Enable foreground dispatch to the current activity.
The foreground dispatch system allows an activity to intercept an intent and claim priority over other activities that handle the same intent.
When using foreground dispatching, you must process the pause and resume events on the activity. See the Foreground Dispatch example
for an example of enabling and disabling foreground dispatch during these events.
See also: [enableForegroundDispatch](http://developer.android.com/reference/android/nfc/NfcAdapter.html#enableForegroundDispatch(android.app.Activity, android.app.PendingIntent, android.content.IntentFilter[], java.lang.String[][]))
| Parameters | Type | Description |
|---|---|---|
| dispatchFilter | Modules.Nfc.NfcForegroundDispatchFilter | A filter specifying intent, intent filters and technology lists used to match dispatch intents. |
Enable NDEF message push over P2P.
This method was deprecated in API level 14. Use setNdefPushMessage instead.
| Parameters | Type | Description |
|---|---|---|
| message | Modules.Nfc.NdefMessage | An NDEF message to push over NFC. |
Enable reader mode in the current activity.
In this mode the NFC controller will only act as an NFC tag reader/writer, thus disabling any peer-to-peer (Android Beam) and card-emulation modes of the NFC adapter on this device.
See also: Android Developer - enableReaderMode
| Parameters | Type | Description |
|---|---|---|
| Callback | Callback | Tag data |
Return true if this NFC Adapter has any features enabled.
Return true if the NDEF Push (Android Beam) feature is enabled.
Processes a new intent received by an application.
The NFC tag dispatch system will dispatch an intent to your application when it discovers a tag
that matches your application's intent filters. Intents received by your application after it has
started MUST be passed to this method in order to be processed and parsed for processing by your
application. If the intent is recognized as an NFC action, this method will call your
onNdefDiscovered, onTagDiscovered, or onTechDiscovered' callback with the parsed information. You should add an event listener to the current activity for the newintent` event in your application
and call this method with the received intent.
| Parameters | Type | Description |
|---|---|---|
| intent | Titanium.Android.Intent | The Android intent received by your application |
Set one or more Uris to send using Android Beam.
See also [setBeamPushUris](http://developer.android.com/reference/android/nfc/NfcAdapter.html#setBeamPushUris(android.net.Uri[], android.app.Activity))
| Parameters | Type | Description |
|---|---|---|
| Uris | Array<String> | An array of Uri(s) to push over Android Beam. |
Set a static Modules.Nfc.NdefMessage to send using Android Beam.
See also: [setNdefPushMessage](http://developer.android.com/reference/android/nfc/NfcAdapter.html#setNdefPushMessage(android.nfc.NdefMessage, android.app.Activity, android.app.Activity...))
| Parameters | Type | Description |
|---|---|---|
| message | Modules.Nfc.NdefMessage | An NDEF message to push over NFC, or null to disable. |
Modules.Nfc.NfcForegroundDispatchFilter
Extends Titanium.Proxy
A filter specifying intent, intent filters and technology lists used to match dispatch intents.
The Modules.Nfc.NfcAdapter.enableForegroundDispatch method is used to give priority to the foreground activity when dispatching a discovered tag to an application. This proxy is used to specify the intent, intent filters, and technology lists used to filter the dispatched intents. This proxy automatically creates the required pending intent and will create an intent for the current activity if one is not provided.
Use the Modules.Nfc.createNfcForegroundDispatchFilter method to create a foreground dispatch filter.
See also: enableForegroundDispatch
Examples
Foreground Dispatch filter
This example creates a dispatch filter used to filter NDEF messages that are of mime type 'text/plain' or
URI from 'http://www.appcelerator.com'. Additionally, the filter will match tags with the specified
technologies. The dispatch filter is then used when calling the enableForegroundDispatch API of the
<Modules.Nfc.NfcAdapter> proxy.
dispatchFilter = nfc.createNfcForegroundDispatchFilter({
intentFilters: [
{ action: nfc.ACTION_NDEF_DISCOVERED, mimeType: 'text/plain' },
{ action: nfc.ACTION_NDEF_DISCOVERED, scheme: 'http', host: 'www.appcelerator.com' }
],
techLists: [
[ "android.nfc.tech.NfcF", "android.nfc.tech.NfcA", "android.nfc.Ndef" ],
[ "android.nfc.tech.Ndef" ],
[ "android.nfc.tech.MifareClassic" ],
[ "android.nfc.tech.NfcA" ]
]
});
// All tag scans are received by the activity as a new intent. Each
// scan intent needs to be passed to the nfc adapter for processing.
var act = Ti.Android.currentActivity;
act.addEventListener('newintent', function(e) {
nfcAdapter.onNewIntent(e.intent);
});
// To enable NFC dispatching only while the application is in the foreground,
// the application must signal the module whenever the application state changes.
act.addEventListener('resume', function(e) {
nfcAdapter.enableForegroundDispatch(dispatchFilter);
});
act.addEventListener('pause', function(e) {
nfcAdapter.disableForegroundDispatch();
});
Properties 3
The intent to start the dispatch when matched.
This optional property allows you to override the default behavior for dispatching the intent. If an intent is not provided (the default behavior), then an intent based on the current activity is automatically created with a flag of FLAG_ACTIVITY_SINGLE_TOP.
intentFilters
Array<NfcIntentFilter>The intent filters to override dispatching for, or null to always dispatch.
techLists
Array<Array<String>>The tech lists used to perform matching for dispatching the ACTION_TECH_DISCOVERED intent.
Modules.Nfc.NfcNDEFTag
Extends Titanium.Proxy
An interface for interacting with an NDEF tag.
It provide the interface for NFC Data Exchange Format (NDEF) tag.
Methods 1
available
iPhoneA value that determines whether the NDEF tag is available in the current reader session.
Modules.Nfc.NfcNDEFTagTechnology
Extends Titanium.Proxy
Provides access to NDEF tag and I/O operations on a Modules.Nfc.NfcNDEFTag
Use the <Modules.Nfc.createTagTechNdef> method to create this NDEF tag technology.
Methods 5
Call to connect NfcNDEFTag from session NFCNDEFReaderSession, connection success or failure result in a didConnectTag event.
Asks the reader session for the NDEF support status of the tag. Success/Failure result in a didQueryNDEFStatus event.
Retrieves an NDEF message from the tag. Success/Failure result in a didReadNDEFMessage event.
Changes the NDEF tag status to read-only, preventing future write operations. Success/Failure result in a didWriteLock event.
Saves an NDEF message to a writable tag. Success/Failure result in a didWirteNDEFMessage event.
Events 5
A event called when NFCNDEFReaderSession try to connect with NDEF tag
A tag stays connected until your app connects to a different tag or restarts polling. Connecting to a tag that is already connected has no effect.
| Event properties | Type | Description |
|---|---|---|
| errorCode | Number | The error code. |
| errorDescription | String | A string containing the localized description of the error. |
| errorDomain | String | A string containing the error domain. |
Asks the reader session for the NDEF support status of the tag.
Asks the reader session (NFCNDEFReaderSession) for the NDEF support status of the tag.
| Event properties | Type | Description |
|---|---|---|
| errorCode | Number | The error code. |
| errorDescription | String | A string containing the localized description of the error. |
| errorDomain | String | A string containing the error domain. |
| status | Number | Constants that indicate status for an NDEF tag. |
| capacity | Number | Indicates the maximum NDEF message size, in bytes, that you can store on the tag. |
Retrieves an NDEF message from the tag.
Retrieves an NDEF message from the tag.
| Event properties | Type | Description |
|---|---|---|
| errorCode | Number | The error code. |
| errorDescription | String | A string containing the localized description of the error. |
| errorDomain | String | A string containing the error domain. |
| message | Modules.Nfc.NdefMessage | An NFC NDEF message consisting of an array of payload records. |
Saves an NDEF message to a writable tag.
To determine whether the tag is writable, call queryNDEFStatus and check that the status is NFC_NDEF_READ_WRITE.
| Event properties | Type | Description |
|---|---|---|
| errorCode | Number | The error code. |
| errorDescription | String | A string containing the localized description of the error. |
| errorDomain | String | A string containing the error domain. |
Changes the NDEF tag status to read-only, preventing future write operations.
Calling this method updates the write access condition byte in the NDEF File Control of the tag's file system, thus locking the tag. This is a permanent action that you cannot undo. After locking the tag, you can no longer write data to it.
| Event properties | Type | Description |
|---|---|---|
| errorCode | Number | The error code. |
| errorDescription | String | A string containing the localized description of the error. |
| errorDomain | String | A string containing the error domain. |
Modules.Nfc.NfcTag
Extends Titanium.Proxy
Represents an NFC tag that has been discovered
See also: Tag
Properties 2
Methods 3
available
iPhoneReturns if the tag is available in current session
Returns the tag identifier (if it has one)
Returns the technologies available in this tag, as fully qualified class names.
Modules.Nfc.TagTechnology
Extends Titanium.Proxy
Represents an interface to a specific tag technology.
NFC tags are based on a number of independently developed technologies and offer a wide range of capabilities. The TagTechnology proxies provide access to these different technologies and capabilities. The TagTechnology proxy is the base type for more type-specific tag technologies. You will work with the type-specific tag technology proxies which provide capabilities for each tag technology.
Use one of the Modules.Nfc.createTagTechnologyIsoDep, Modules.Nfc.createTagTechnologyMifareClassic, Modules.Nfc.createTagTechnologyMifareUltralight, Modules.Nfc.createTagTechnologyNdefFormatable, Modules.Nfc.createTagTechnologyNdef, Modules.Nfc.createTagTechnologyNfcA, Modules.Nfc.createTagTechnologyNfcB, Modules.Nfc.createTagTechnologyNfcF, Modules.Nfc.createTagTechnologyNfcV method variants to create a tag technology proxy.
See also: TagTechnology
Examples
Write Ndef Tag
This example uses the TECH_NDEF tag technology to write a <Modules.Nfc.NdefMessage> message to a tag.
var tech = nfc.createTagTechnologyNdef({
tag: scannedTag
});
if (!tech.isValid()) {
alert("Failed to create Ndef tag type");
return;
}
// Attempt to write an Ndef record to the tag
try {
tech.connect();
// It's possible that the tag is not writable, so we need to check first.
if (!tech.isWritable()) {
alert ("Tag is not writable");
} else {
// Create a new message to write to the tag
var date = new Date();
var textRecord = nfc.createNdefRecordText({
text: "Titanium NFC module. Tag updated on " + date.toLocaleString() + "!!!"
});
var msg = nfc.createNdefMessage({
records: [ textRecord ]
});
// Write to the tag
tech.writeNdefMessage(msg);
}
} catch (e) {
alert("Error: " + e.message);
} finally {
if (tech.isConnected()) {
tech.close();
}
}
Properties 1
The tag technology that has been discovered.
When a tag is discovered, a Modules.Nfc.NfcTag proxy is created and passed as a property to the onNdefDiscovered, onTagDiscovered, or
onTechDiscovered callback (see NdefDiscovered).
Methods 4
Disable I/O operations to the tag and release resources.
Enable I/O operations to the tag.
Only one Tag Technology proxy can be connected to a Tag at a time.
Returns true if connect has completed, and close has not been called, and the tag is not known to be out of range.
Return true if this tag technology was successfully obtained.
Modules.Nfc.TagTechnologyIsoDep
Extends Modules.Nfc.TagTechnologyTitanium.Proxy
Provides access to ISO-DEP (ISO 14443-4) properties and I/O operations on a Modules.Nfc.NfcTag.
Use the Modules.Nfc.createTagTechnologyIsoDep method to create this tag technology.
See also: IsoDep
Properties 1
Inherited from Modules.Nfc.TagTechnology
The tag technology that has been discovered.
Methods 11
Inherited from Modules.Nfc.TagTechnology
Disable I/O operations to the tag and release resources.
Inherited from Modules.Nfc.TagTechnology
Enable I/O operations to the tag.
Return the higher layer response bytes for NfcB tags.
Return the ISO-DEP historical bytes for NfcA tags.
Return the maximum number of bytes that can be sent with transceive.
Get the current timeout for transceive in milliseconds.
Inherited from Modules.Nfc.TagTechnology
Returns true if connect has completed, and close has not been called, and the tag is not known to be out of range.
Whether the NFC adapter on this device supports extended length APDUs.
Inherited from Modules.Nfc.TagTechnology
Return true if this tag technology was successfully obtained.
Set the timeout of transceive in milliseconds.
| Parameters | Type | Description |
|---|---|---|
| timeout | Number | Timeout value in milliseconds |
Send raw ISO-DEP data to the tag and receive the response.
| Parameters | Type | Description |
|---|---|---|
| data | Titanium.Buffer | Bytes to send. |
Modules.Nfc.TagTechnologyMifareClassic
Extends Modules.Nfc.TagTechnologyTitanium.Proxy
Provides access to MIFARE Classic properties and I/O operations on a Modules.Nfc.NfcTag.
Use the Modules.Nfc.createTagTechnologyMifareClassic method to create this tag technology.
See also: MifareClassic
Properties 4
The default factory key.
The well-known key for tags formatted according to the MIFARE Application Directory (MAD) specification.
The well-known key for tags formatted according to the NDEF on MIFARE Classic specification.
Inherited from Modules.Nfc.TagTechnology
The tag technology that has been discovered.
Methods 23
Authenticate a sector with key A.
| Parameters | Type | Description |
|---|---|---|
| sectorIndex | Number | Index of sector to authenticate, starting from 0. |
| key | Titanium.Buffer | 6-byte authentication key. |
Returns true on success, false on authentication failure.
Authenticate a sector with key B.
| Parameters | Type | Description |
|---|---|---|
| sectorIndex | Number | Index of sector to authenticate, starting from 0. |
| key | Titanium.Buffer | 6-byte authentication key. |
Returns true on success, false on authentication failure.
Return the sector that contains a given block.
| Parameters | Type | Description |
|---|---|---|
| blockIndex | Number | Index of block to lookup, starting from 0. |
Inherited from Modules.Nfc.TagTechnology
Disable I/O operations to the tag and release resources.
Inherited from Modules.Nfc.TagTechnology
Enable I/O operations to the tag.
Decrement a value block, storing the result in the temporary block on the tag.
| Parameters | Type | Description |
|---|---|---|
| blockIndex | Number | Index of block to decrement, starting from 0. |
| value | Number | Non-negative to decrement by. |
Return the total number of MIFARE Classic blocks.
Return the number of blocks in the given sector.
| Parameters | Type | Description |
|---|---|---|
| sectorIndex | Number | Index of sector, starting from 0. |
Return the maximum number of bytes that can be sent with transceive.
Return the number of MIFARE Classic sectors.
Return the size of the tag in bytes.
Get the current transceive timeout in milliseconds.
Return the type of this MIFARE Classic compatible tag.
Increment a value block, storing the result in the temporary block on the tag.
| Parameters | Type | Description |
|---|---|---|
| blockIndex | Number | Index of block to increment, starting from 0. |
| value | Number | Non-negative to increment by. |
Inherited from Modules.Nfc.TagTechnology
Returns true if connect has completed, and close has not been called, and the tag is not known to be out of range.
Inherited from Modules.Nfc.TagTechnology
Return true if this tag technology was successfully obtained.
Read 16-byte block.
| Parameters | Type | Description |
|---|---|---|
| blockIndex | Number | Index of block to read, starting from 0. |
Copy from a value block to the temporary block.
| Parameters | Type | Description |
|---|---|---|
| blockIndex | Number | Index of block to copy from. |
Return the first block of a given sector.
| Parameters | Type | Description |
|---|---|---|
| sectorIndex | Number | Index of sector to lookup, starting from 0. |
Set the transceive timeout in milliseconds.
| Parameters | Type | Description |
|---|---|---|
| timeout | Number | Timeout value in milliseconds. |
Send raw NfcA data to the tag and receive the response.
| Parameters | Type | Description |
|---|---|---|
| data | Titanium.Buffer | Bytes to send. |
Copy from the temporary block to a value block.
| Parameters | Type | Description |
|---|---|---|
| blockIndex | Number | Index of block to copy to. |
Write 16-byte block.
| Parameters | Type | Description |
|---|---|---|
| blockIndex | Number | Index of block to write, starting from 0. |
| data | Titanium.Buffer | 16 bytes of data to write. |
Modules.Nfc.TagTechnologyMifareUltralight
Extends Modules.Nfc.TagTechnologyTitanium.Proxy
Provides access to MIFARE Ultralight properties and I/O operations on a Modules.Nfc.NfcTag.
Use the Modules.Nfc.createTagTechnologyMifareUltralight method to create this tag technology.
See also: MifareUltralight
Properties 1
Inherited from Modules.Nfc.TagTechnology
The tag technology that has been discovered.
Methods 11
Inherited from Modules.Nfc.TagTechnology
Disable I/O operations to the tag and release resources.
Inherited from Modules.Nfc.TagTechnology
Enable I/O operations to the tag.
Return the maximum number of bytes that can be sent with transceive.
Get the current transceive timeout in milliseconds.
Return the MIFARE Ultralight type of the tag.
One of MIFARE_ULTRALIGHT_TYPE_ULTRALIGHT, MIFARE_ULTRALIGHT_TYPE_ULTRALIGHT_C, or MIFARE_ULTRALIGHT_TYPE_UNKNOWN.
Inherited from Modules.Nfc.TagTechnology
Returns true if connect has completed, and close has not been called, and the tag is not known to be out of range.
Inherited from Modules.Nfc.TagTechnology
Return true if this tag technology was successfully obtained.
Read 4 pages (16 bytes).
| Parameters | Type | Description |
|---|---|---|
| pageOffset | Number | Index of first page to read, starting from 0. |
Set the transceive timeout in milliseconds.
| Parameters | Type | Description |
|---|---|---|
| timeout | Number | Timeout value in milliseconds. |
Send raw NfcA data to the tag and receive the response.
| Parameters | Type | Description |
|---|---|---|
| data | Titanium.Buffer | Bytes to send. |
Write 1 page (4 bytes).
| Parameters | Type | Description |
|---|---|---|
| pageOffset | Number | Index of page to write, starting from 0. |
| data | Titanium.Buffer | 4 bytes to write. |
Modules.Nfc.TagTechnologyNdef
Extends Modules.Nfc.TagTechnologyTitanium.Proxy
Provides access to NDEF content and operations on a Modules.Nfc.NfcTag.
Use the Modules.Nfc.createTagTechnologyNdef method to create this tag technology.
See also: Ndef
Properties 1
Inherited from Modules.Nfc.TagTechnology
The tag technology that has been discovered.
Methods 12
Indicates whether a tag can be made read-only with makeReadOnly.
true if it is possible to make this tag read-only.
Inherited from Modules.Nfc.TagTechnology
Disable I/O operations to the tag and release resources.
Inherited from Modules.Nfc.TagTechnology
Enable I/O operations to the tag.
Get the Modules.Nfc.NdefMessage that was read from the tag at discovery time.
Get the maximum NDEF message size in bytes.
Read the current Modules.Nfc.NdefMessage on this tag.
Get the NDEF tag type.
One of TAG_TYPE_NFC_FORUM_TYPE_1, TAG_TYPE_NFC_FORUM_TYPE_2, TAG_TYPE_NFC_FORUM_TYPE_3, TAG_TYPE_NFC_FORUM_TYPE_4, TAG_TYPE_MIFARE_CLASSIC, or another NDEF tag type that has not yet been formalized in the Android API.
Inherited from Modules.Nfc.TagTechnology
Returns true if connect has completed, and close has not been called, and the tag is not known to be out of range.
Inherited from Modules.Nfc.TagTechnology
Return true if this tag technology was successfully obtained.
Determine if the tag is writable.
true if the tag is writable.
Make a tag read-only.
true on success, false if it is not possible to make this tag read-only.
Overwrite the Modules.Nfc.NdefMessage on this tag.
| Parameters | Type | Description |
|---|---|---|
| message | Modules.Nfc.NdefMessage | The Modules.Nfc.NdefMessage to write |
Modules.Nfc.TagTechnologyNdefFormatable
Extends Modules.Nfc.TagTechnologyTitanium.Proxy
Provide access to NDEF format operations on a Modules.Nfc.NfcTag.
Use the Modules.Nfc.createTagTechnologyNdefFormatable method to create this tag technology.
See also: NdefFormatable
Properties 1
Inherited from Modules.Nfc.TagTechnology
The tag technology that has been discovered.
Methods 6
Inherited from Modules.Nfc.TagTechnology
Disable I/O operations to the tag and release resources.
Inherited from Modules.Nfc.TagTechnology
Enable I/O operations to the tag.
Format a tag as NDEF, and write a Modules.Nfc.NdefMessage.
| Parameters | Type | Description |
|---|---|---|
| message | Modules.Nfc.NdefMessage | The NDEF message to write after formatting, can be null. |
Formats a tag as NDEF, write a Modules.Nfc.NdefMessage, and make read-only.
| Parameters | Type | Description |
|---|---|---|
| message | Modules.Nfc.NdefMessage | The NDEF message to write after formatting |
Inherited from Modules.Nfc.TagTechnology
Returns true if connect has completed, and close has not been called, and the tag is not known to be out of range.
Inherited from Modules.Nfc.TagTechnology
Return true if this tag technology was successfully obtained.
Modules.Nfc.TagTechnologyNfcA
Extends Modules.Nfc.TagTechnologyTitanium.Proxy
Provides access to NFC-A (ISO 14443-3A) properties and I/O operations on a Modules.Nfc.NfcTag.
Use the Modules.Nfc.createTagTechnologyNfcA method to create this tag technology.
See also: NfcA
Properties 1
Inherited from Modules.Nfc.TagTechnology
The tag technology that has been discovered.
Methods 10
Inherited from Modules.Nfc.TagTechnology
Disable I/O operations to the tag and release resources.
Inherited from Modules.Nfc.TagTechnology
Enable I/O operations to the tag.
Return the ATQA/SENS_RES bytes from tag discovery.
Return the maximum number of bytes that can be sent with transceive.
Return the SAK/SEL_RES bytes from tag discovery.
SAK bytes.
Get the current transceive timeout in milliseconds.
Inherited from Modules.Nfc.TagTechnology
Returns true if connect has completed, and close has not been called, and the tag is not known to be out of range.
Inherited from Modules.Nfc.TagTechnology
Return true if this tag technology was successfully obtained.
Set the timeout of transceive in milliseconds.
| Parameters | Type | Description |
|---|---|---|
| timeout | Number | Timeout value in milliseconds |
Send raw NFC-A commands to the tag and receive the response.
| Parameters | Type | Description |
|---|---|---|
| data | Titanium.Buffer | Bytes to send. |
Modules.Nfc.TagTechnologyNfcB
Extends Modules.Nfc.TagTechnologyTitanium.Proxy
Provides access to NFC-B (ISO 14443-3B) properties and I/O operations on a Modules.Nfc.NfcTag.
Use the Modules.Nfc.createTagTechnologyNfcB method to create this tag technology.
See also: NfcB
Properties 1
Inherited from Modules.Nfc.TagTechnology
The tag technology that has been discovered.
Methods 8
Inherited from Modules.Nfc.TagTechnology
Disable I/O operations to the tag and release resources.
Inherited from Modules.Nfc.TagTechnology
Enable I/O operations to the tag.
Return the Application Data bytes from ATQB/SENSB_RES at tag discovery.
Return the maximum number of bytes that can be sent with transceive.
Return the Protocol Info bytes from ATQB/SENSB_RES at tag discovery.
Inherited from Modules.Nfc.TagTechnology
Returns true if connect has completed, and close has not been called, and the tag is not known to be out of range.
Inherited from Modules.Nfc.TagTechnology
Return true if this tag technology was successfully obtained.
Send raw NFC-B commands to the tag and receive the response.
| Parameters | Type | Description |
|---|---|---|
| data | Titanium.Buffer | Bytes to send. |
Modules.Nfc.TagTechnologyNfcF
Extends Modules.Nfc.TagTechnologyTitanium.Proxy
Provides access to NFC-F (JIS 6319-4) properties and I/O operations on a Modules.Nfc.NfcTag.
Use the Modules.Nfc.createTagTechnologyNfcF method to create this tag technology.
See also: NfcF
Properties 1
Inherited from Modules.Nfc.TagTechnology
The tag technology that has been discovered.
Methods 10
Inherited from Modules.Nfc.TagTechnology
Disable I/O operations to the tag and release resources.
Inherited from Modules.Nfc.TagTechnology
Enable I/O operations to the tag.
Return the Manufacturer bytes from tag discovery.
Return the maximum number of bytes that can be sent with transceive.
Return the System Code bytes from tag discovery.
Get the current transceive timeout in milliseconds.
Inherited from Modules.Nfc.TagTechnology
Returns true if connect has completed, and close has not been called, and the tag is not known to be out of range.
Inherited from Modules.Nfc.TagTechnology
Return true if this tag technology was successfully obtained.
Set the timeout of transceive in milliseconds.
| Parameters | Type | Description |
|---|---|---|
| timeout | Number | Timeout value in milliseconds |
Send raw NFC-F commands to the tag and receive the response.
| Parameters | Type | Description |
|---|---|---|
| data | Titanium.Buffer | Bytes to send. |
Modules.Nfc.TagTechnologyNfcV
Extends Modules.Nfc.TagTechnologyTitanium.Proxy
Provides access to NFC-V (ISO 15693) properties and I/O operations on a Modules.Nfc.NfcTag.
Use the Modules.Nfc.createTagTechnologyNfcV method to create this tag technology.
See also: NfcV
Properties 1
Inherited from Modules.Nfc.TagTechnology
The tag technology that has been discovered.
Methods 8
Inherited from Modules.Nfc.TagTechnology
Disable I/O operations to the tag and release resources.
Inherited from Modules.Nfc.TagTechnology
Enable I/O operations to the tag.
Return the DSF ID bytes from tag discovery.
Return the maximum number of bytes that can be sent with transceive.
Return the Response Flag bytes from tag discovery.
Response Flag bytes.
Inherited from Modules.Nfc.TagTechnology
Returns true if connect has completed, and close has not been called, and the tag is not known to be out of range.
Inherited from Modules.Nfc.TagTechnology
Return true if this tag technology was successfully obtained.
Send raw NFC-V commands to the tag and receive the response.
| Parameters | Type | Description |
|---|---|---|
| data | Titanium.Buffer | Bytes to send. |
NdefDiscovered
Argument passed to the callback when an NDEF message, tag, or technology is discovered.
Properties 4
Identifies the action from the intent.
This value will be one of the constants defined on the Modules.Nfc module object (ACTION_NDEF_DISCOVERED, ACTION_TAG_DISCOVERED, or ACTION_TECH_DISCOVERED).
The error code returned if an error occurred while reading the tag.
Array of NDEF messages parsed from the tag.
NFC tag proxy identifying the tag was was discovered.