There are three groups of application scenarios for NFC:
For more information on the NFC features, see NFC Guide.
Since: 2.3.1
enum NDEFRecordTextEncoding { "UTF8", "UTF16" };
Since: 2.3.1
enum NFCTagType { "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", "UNKNOWN_TARGET" };
Since: 2.3.1
The following values are supported:
enum CardEmulationMode { "ALWAYS_ON", "OFF" };
Since: 2.3.1
The following values are supported:
enum SecureElementType { "ESE", "UICC", "HCE" };
Since: 2.3.1
The following values are supported:
Remark : HCE is supported since Tizen 2.3.1
enum CardEmulationCategoryType { "PAYMENT", "OTHER" };
Since: 2.3.1
The following values are supported:
[NoInterfaceObject] interface NFCManagerObject { readonly attribute NFCManager nfc; };
Tizen implements NFCManagerObject;
Since: 2.3.1
[NoInterfaceObject] interface NFCManager { const short NFC_RECORD_TNF_EMPTY = 0; const short NFC_RECORD_TNF_WELL_KNOWN = 1; const short NFC_RECORD_TNF_MIME_MEDIA = 2; const short NFC_RECORD_TNF_URI = 3; const short NFC_RECORD_TNF_EXTERNAL_RTD = 4; const short NFC_RECORD_TNF_UNKNOWN = 5; const short NFC_RECORD_TNF_UNCHANGED = 6; NFCAdapter getDefaultAdapter() raises(WebAPIException); void setExclusiveMode(boolean mode) raises(WebAPIException); };
Since: 2.3.1
It provides access to the API functionalities through the tizen.nfc interface.
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
getDefaultAdapter
NFCAdapter getDefaultAdapter();
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.common
Return value:
NFCAdapter The default NFCAdapter object.Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, in any other error case.
Code example:
try { var adapter = tizen.nfc.getDefaultAdapter(); } catch (err) { console.log(err.name +": " + err.message); }
setExclusiveMode
void setExclusiveMode(boolean mode);
Since: 2.3.1
If the current application has priority, and is in the foreground, the system will not generate application control requests to pick an application to handle NFC requests. Such a request is usually generated, for example, when detecting an NFC tag or receiving an NDEF message from a connected NFC peer-to-peer target.
When the current application moves to the background, it loses the priority.
The exclusive mode can only be set when NFC is on. If NFC is off, the mode is ignored.
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.common
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, in any other error case.
Code example:
try { tizen.nfc.setExclusiveMode(true) ; } catch (err) { console.log(err.name + ": " + err.message); }
[NoInterfaceObject] interface NFCAdapter { readonly attribute boolean powered; attribute CardEmulationMode cardEmulationMode raises(WebAPIException); attribute SecureElementType? activeSecureElement raises(WebAPIException); void setPowered(boolean state, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void setTagListener(NFCTagDetectCallback detectCallback, optional NFCTagType[]? tagFilter) raises(WebAPIException); void setPeerListener(NFCPeerDetectCallback detectCallback) raises(WebAPIException); void unsetTagListener() raises(WebAPIException); void unsetPeerListener() raises(WebAPIException); long addCardEmulationModeChangeListener(CardEmulationModeChangeCallback changeCallback) raises(WebAPIException); void removeCardEmulationModeChangeListener(long watchId) raises(WebAPIException); long addTransactionEventListener(SecureElementType type, TransactionEventCallback eventCallback) raises(WebAPIException); void removeTransactionEventListener(long watchId) raises(WebAPIException); long addActiveSecureElementChangeListener(ActiveSecureElementChangeCallback changeCallback) raises(WebAPIException); void removeActiveSecureElementChangeListener(long watchId) raises(WebAPIException); NDEFMessage? getCachedMessage() raises(WebAPIException); void setExclusiveModeForTransaction(boolean mode) raises(WebAPIException); long addHCEEventListener(HCEEventReceiveCallback eventCallback) raises(WebAPIException); void removeHCEEventListener(long watchId) raises(WebAPIException); void sendHostAPDUResponse(byte[] apdu, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); boolean isActivatedHandlerForAID(SecureElementType type, AID aid) raises(WebAPIException); boolean isActivatedHandlerForCategory(SecureElementType type, CardEmulationCategoryType category) raises(WebAPIException); void registerAID(SecureElementType type, AID aid, CardEmulationCategoryType category) raises(WebAPIException); void unregisterAID(SecureElementType type, AID aid, CardEmulationCategoryType category) raises(WebAPIException); void getAIDsForCategory(SecureElementType type, CardEmulationCategoryType category, AIDArraySuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.3.1
Since: 2.3.1
To be allowed to change cardEmulationMode, the following privilege must be declared in the application's config.xml file.
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Remark :
To check if NFC card emulation is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.card_emulation").
If it is not supported, NotSupportedError is thrown.
Security level can be determined by the manufacturer usage.
If a security issue is occurred, contact with the manufacturer of the product.
If you want to know about security level in detail, See the GSMA specification.
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege or a valid certificate to call this method.
with error type ServiceNotAvailableError, if the NFC service is not available.
with error type NotSupportedError, if NFC card emulation is not supported in a device.
with error type UnknownError, if any other error occurs.
To be allowed to change activeSecureElement, the following privilege must be declared in the application's config.xml file.
If the NFC service is not available, it returns null.
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Remark :
To check if NFC card emulation is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.card_emulation").
If it is not supported, NotSupportedError is thrown.
Security level can be determined by the manufacturer usage.
If a security issue is occurred, contact with the manufacturer of the product.
If you want to know about security level in detail, See the GSMA specification.
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege or a valid certificate to call this method.
with error type ServiceNotAvailableError, if the NFC service is not available.
with error type NotSupportedError, if NFC card emulation is not supported in a device.
with error type UnknownError, if any other error occurs.
setPowered
Deprecated. It is deprecated since Tizen 2.3 and will be removed in Tizen 3.0. Instead, let the user turn NFC on/off through the Settings application. See the Managing NFC Tutorial.
void setPowered(boolean state, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.admin
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if this functionality is not allowed.
Code example:
var gNfcAdapter; var onPowerOn = function(){ // Called when NFC adapter is powered on try { console.log("Power on succeed"); // Implement NFC communication routines ... gNfcAdapter.setPowered( false, // Disable NFC adapter function () {console.log("Power off succeed"); }, // Handle success function () {console.log("Power off failed"); }); // Handle failure } catch (err) { console.log(err.name + ": " + err.message); } }; try { gNfcAdapter = tizen.nfc.getDefaultAdapter(); if (!gNfcAdapter.powered) { gNfcAdapter.setPowered( true, // Enable NFC adapter onPowerOn, // Handle success function () {console.log("Power on failed")}); // Handle failure } else { onPowerOn(); } } catch (err) { console.log(err.name + ": " + err.message); }
setTagListener
void setTagListener(NFCTagDetectCallback detectCallback, optional NFCTagType[]? tagFilter);
Since: 2.3.1
If the registration completes successfully, detectCallback must be invoked when the NFC tag is detected.
If no tagFilter is passed, it shall consider the default tagFilter, that is to set all tag types.
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.tag
Remark : http://tizen.org/feature/network.nfc.tag is added since Tizen 2.3.1. to check if NFC tag is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.tag").
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type ServiceNotAvailableError, if the NFC service is not available.
with error type NotSupportedError, if NFC tag is not supported.
with error type UnknownError, in any other error case.
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); var onSuccessCB = {onattach : function(nfcTag) { console.log("NFC Tag's type is " + nfcTag.type); }, ondetach : function() { console.log("NFC Tag is detached"); }}; adapter.setTagListener(onSuccessCB);
setPeerListener
void setPeerListener(NFCPeerDetectCallback detectCallback);
Since: 2.3.1
If the registration completes successfully, the detectCallback must be invoked when an NFC peer-to-peer target is detected.
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.p2p
Remark : http://tizen.org/feature/network.nfc.p2p is added since Tizen 2.3.1. to check if NFC p2p is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.p2p").
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type ServiceNotAvailableError, if the NFC service is not available.
with error type NotSupportedError, if NFC p2p is not supported.
with error type UnknownError, in any other error case.
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); var onSuccessCB = {onattach : function(nfcPeer) { console.log("NFC Target is detected"); }, ondetach : function() { console.log("NFC Target is detached"); }}; adapter.setPeerListener(onSuccessCB);
unsetTagListener
void unsetTagListener();
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.tag
Remark : http://tizen.org/feature/network.nfc.tag is added since Tizen 2.3.1. to check if NFC tag is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.tag").
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type ServiceNotAvailableError, if the NFC service is not available.
with error type NotSupportedError, if NFC tag is not supported.
with error type UnknownError, in any other error case.
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); // Receives NFCTag var onSuccessCB = { onattach : function(nfcTag) { console.log("The attached NFC tag's type is " + nfcTag.type); }, ondetach : function() { console.log("NFC tag is detached."); // Unregister the listener when the NFC tag is detached. adapter.unsetTagListener(); } }; // Registers to be notified when NFC tag is detected. adapter.setTagListener(onSuccessCB);
unsetPeerListener
void unsetPeerListener();
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.p2p
Remark : http://tizen.org/feature/network.nfc.p2p is added since Tizen 2.3.1. to check if NFC p2p is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.p2p").
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type ServiceNotAvailableError, if the NFC service is not available.
with error type NotSupportedError, if NFC p2p is not supported.
with error type UnknownError, in any other error case.
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); // Receives an NFC peer. var onSuccessCB = { onattach : function(nfcPeer) { console.log("NFC peer target is attached."); }, ondetach : function() { console.log("NFC peer target is detached."); // Unregisters the listener when NFC peer target is detached. adapter.unsetPeerListener(); } }; // Registers to be notified when NFC peer target is detected. adapter.setPeerListener(onSuccessCB);
addCardEmulationModeChangeListener
long addCardEmulationModeChangeListener(CardEmulationModeChangeCallback changeCallback);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Parameters:
Return value:
long Subscription identifierExceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC card emulation is not supported.
with error type UnknownError, in any other error case.
Code example:
try { var onSuccessCB = function(mode) { console.log("The card emulation mode is " + mode); }; var listenerId = adapter.addCardEmulationModeChangeListener(onSuccessCB) ; } catch (err) { console.log(err.name + ": " + err.message); }
removeCardEmulationModeChangeListener
void removeCardEmulationModeChangeListener(long watchId);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC card emulation is not supported.
with error type UnknownError, in any other error case.
Code example:
try { adapter.removeCardEmulationModeChangeListener(listenerId) ; } catch (err) { console.log(err.name + ": " + err.message); }
addTransactionEventListener
long addTransactionEventListener(SecureElementType type, TransactionEventCallback eventCallback);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Parameters:
Return value:
long Subscription identifierExceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC card emulation is not supported.
with error type UnknownError, in any other error case.
Code example:
try { var listenerId = adapter.addTransactionEventListener("UICC", function(aid, data){console.log("transaction event occurs");}) ; } catch (err) { console.log(err.name + ": " + err.message); }
removeTransactionEventListener
void removeTransactionEventListener(long watchId);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC card emulation is not supported.
with error type UnknownError, in any other error case.
Code example:
try { adapter.removeTransactionEventListener(listenerId) ; } catch (err) { console.log(err.name + ": " + err.message); }
addActiveSecureElementChangeListener
long addActiveSecureElementChangeListener(ActiveSecureElementChangeCallback changeCallback);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Parameters:
Return value:
long Subscription identifierExceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC card emulation is not supported.
with error type UnknownError, in any other error case.
Code example:
try { var onSuccessCB = function(seType) { console.log("Active secure element is " + seType); }; var listenerId = adapter.addActiveSecureElementChangeListener(onSuccessCB) ; } catch (err) { console.log(err.name + ": " + err.message); }
removeActiveSecureElementChangeListener
void removeActiveSecureElementChangeListener(long watchId);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC card emulation is not supported.
with error type UnknownError, in any other error case.
Code example:
try { adapter.removeActiveSecureElementChangeListener(listenerId) ; } catch (err) { console.log(err.name + ": " + err.message); }
getCachedMessage
NDEFMessage? getCachedMessage();
Since: 2.3.1
If the operation completes successfully, the NDEF Message that is last read should be returned.
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.common
Return value:
NDEFMessage The NDEF Message that was last read.Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, in any other error case.
Code example:
// Gets the cached message var cachedMessage = tizen.nfc.getDefaultAdapter().getCachedMessage();
setExclusiveModeForTransaction
void setExclusiveModeForTransaction(boolean mode);
Since: 2.3.1
If the current application has priority, and is in the foreground, the system will not generate application control requests to pick an application to handle a transaction event request.
When the current application moves to the background, it loses priority.
An application is allowed to get priority only when it is in the foreground. Losing priority is always allowed regardless of an application's status.
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Remark :
Security level can be determined by the manufacturer usage.
If a security issue is occurred, contact with the manufacturer of the product.
If you want to know about security level in detail, See the GSMA specification.
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method or a valid certificate to call this method.
with error type ServiceNotAvailableError, if the application is not in the foreground and is trying to get priority.
with error type NotSupportedError, if NFC card emulation is not supported.
with error type UnknownError, in any other error case.
Code example:
try { adapter.setExclusiveModeForTransaction(true) ; } catch (err) { console.log(err.name + ": " + err.message); }
addHCEEventListener
long addHCEEventListener(HCEEventReceiveCallback eventCallback);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Remark :
To check if NFC HCE is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.card_emulation.hce").
If it is not supported, NotSupportedError is thrown.
Parameters:
Return value:
long Subscription identifierExceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC HCE is not supported.
with error type UnknownError, in any other error case.
Code example:
try { var onDetectedCB = function(event_data) { console.log("HCE event type is " + event_data.eventType); console.log("APDU is " + event_data.apdu); }; var listenerId = adapter.addHCEEventListener(onDetectedCB) ; } catch (err) { console.log(err.name + ": " + err.message); }
removeHCEEventListener
void removeHCEEventListener(long watchId);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC HCE is not supported.
with error type UnknownError, in any other error case.
Code example:
try { adapter.removeHCEEventListener(listenerId) ; } catch (err) { console.log(err.name + ": " + err.message); }
sendHostAPDUResponse
void sendHostAPDUResponse(byte[] apdu, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Remark :
To check if NFC HCE is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.card_emulation.hce").
If it is not supported, NotSupportedError is thrown.
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC HCE is not supported.
Code example:
try { var successCB = function() { console.log("Sending APDU reponse was successful."); }; var errorCB = function() { console.log("Sending APDU reponse failed."); }; var apdu_response= [0x00,0xA4,0x04,0x00,0x04,0x11,0x12, 0x13, 0x14]; //set apdu response. adapter.sendHostAPDUResponse(apdu_response, successCB, errorCB) ; } catch (err) { console.log(err.name + ": " + err.message); }
isActivatedHandlerForAID
boolean isActivatedHandlerForAID(SecureElementType type, AID aid);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Remark :
To check if NFC HCE is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.card_emulation.hce").
If it is not supported, NotSupportedError is thrown.
Parameters:
Return value:
boolean true if current application is activated handler for the AIDExceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC HCE is not supported.
with error type UnknownError, in any other error case.
Code example:
try { var aid = "ABC0012345"; var isActiveHandler = adapter.isActivatedHandlerForAID("HCE", aid); if(isActiveHandler){ console.log("current application is activated handler for the AID"); } } catch (err) { console.log(err.name + ": " + err.message); }
isActivatedHandlerForCategory
boolean isActivatedHandlerForCategory(SecureElementType type, CardEmulationCategoryType category);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Remark :
To check if NFC HCE is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.card_emulation.hce").
If it is not supported, NotSupportedError is thrown.
Parameters:
Return value:
boolean true if current application is activated handler for the categoryExceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC HCE is not supported.
with error type UnknownError, in any other error case.
Code example:
try { var isActiveHandler = adapter.isActivatedHandlerForCategory("ESE", "PAYMENT") ; if(isActiveHandler){ console.log("current application is activated handler for the category"); } } catch (err) { console.log(err.name + ": " + err.message); }
registerAID
void registerAID(SecureElementType type, AID aid, CardEmulationCategoryType category);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Remark :
To check if NFC HCE is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.card_emulation.hce").
If it is not supported, NotSupportedError is thrown.
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC HCE is not supported.
with error type UnknownError, in any other error case.
Code example:
try { var aid = "ABC0012345"; adapter.registerAID("HCE", aid, "PAYMENT") ; } catch (err) { console.log(err.name + ": " + err.message); }
unregisterAID
void unregisterAID(SecureElementType type, AID aid, CardEmulationCategoryType category);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Remark :
To check if NFC HCE is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.card_emulation.hce").
If it is not supported, NotSupportedError is thrown.
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC HCE is not supported.
with error type UnknownError, in any other error case.
Code example:
try { var aid = "ABC0012345"; adapter.unregisterAID("HCE", aid, "PAYMENT") ; } catch (err) { console.log(err.name + ": " + err.message); }
getAIDsForCategory
void getAIDsForCategory(SecureElementType type, CardEmulationCategoryType category, AIDArraySuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.cardemulation
Remark :
To check if NFC HCE is supported on this device, use tizen.systeminfo.getCapability("http://tizen.org/feature/network.nfc.card_emulation.hce").
If it is not supported, NotSupportedError is thrown.
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type NotSupportedError, if NFC HCE is not supported.
[NoInterfaceObject] interface NFCTag { readonly attribute NFCTagType type; readonly attribute boolean isSupportedNDEF; readonly attribute long ndefSize; readonly attribute object properties; readonly attribute boolean isConnected; void readNDEF(NDEFMessageReadCallback readCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void writeNDEF(NDEFMessage ndefMessage, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void transceive(byte[] data, ByteArraySuccessCallback dataCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
It is pairs of key and value. The array's index is the pair's key and value is its value.
Since: 2.3.1
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); var onSuccessCB = {onattach : function(nfcTag) { console.log("NFC Tag's type is " + nfcTag.type); for(var i in nfcTag.properties) { console.log("key:" + i + " value:" + nfcTag.properties[i]); } }, ondetach : function() { console.log("NFC Tag is detached"); }}; adapter.setTagListener(onSuccessCB);
Since: 2.3.1
readNDEF
void readNDEF(NDEFMessageReadCallback readCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.tag
Remark : If an NFC tag does not support the NDEF standard, InvalidValuesError would be returned instead of NotSupportedError since Tizen 2.3.
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
writeNDEF
void writeNDEF(NDEFMessage ndefMessage, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.tag
Remark : If an NFC tag does not support the NDEF standard, InvalidValuesError would be returned instead of NotSupportedError since Tizen 2.3.
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
transceive
void transceive(byte[] data, ByteArraySuccessCallback dataCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.tag
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
[NoInterfaceObject] interface NFCPeer { readonly attribute boolean isConnected; void setReceiveNDEFListener(NDEFMessageReadCallback successCallback) raises(WebAPIException); void unsetReceiveNDEFListener() raises(WebAPIException); void sendNDEF(NDEFMessage ndefMessage, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.3.1
Since: 2.3.1
setReceiveNDEFListener
void setReceiveNDEFListener(NDEFMessageReadCallback successCallback);
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.p2p
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type ServiceNotAvailableError, if the NFC service is not available.
with error type UnknownError, in any other error case.
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); // Receives NFCPeer var onSuccessCB = {onattach : function(nfcPeer) { console.log("NFC Target is detected"); nfcPeer.setReceiveNDEFListener( function(message){ console.log("Receive message"); }); }, ondetach : function() { console.log("NFC Target is detached"); }}; adapter.setPeerListener(onSuccessCB);
unsetReceiveNDEFListener
void unsetReceiveNDEFListener();
Since: 2.3.1
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.p2p
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type ServiceNotAvailableError, if the NFC service is not available.
with error type UnknownError, in any other error case.
Code example:
var adapter = tizen.nfc.getDefaultAdapter(); var onSuccessCB = {onattach : function(nfcPeer) { console.log("NFC Target is detected"); nfcPeer.setReceiveNDEFListener( function(message){ console.log("Receive message"); nfcPeer.unsetReceiveNDEFListener(); }); }, ondetach : function() { console.log("NFC Target is detached"); }}; } adapter.setPeerListener(onSuccessCB);
sendNDEF
void sendNDEF(NDEFMessage ndefMessage, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
The ErrorCallback is launched with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/nfc.p2p
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
[Constructor(), Constructor(NDEFRecord[] ndefRecords), Constructor(byte[] rawData)] interface NDEFMessage { readonly attribute long recordCount; attribute NDEFRecord[] records; byte[] toByte() raises(WebAPIException); };
Since: 2.3.1
NDEFMessage();
NDEFMessage(NDEFRecord[] ndefRecords);
NDEFMessage(byte[] rawData);
Since: 2.3.1
Since: 2.3.1
toByte
byte[] toByte();
Since: 2.3.1
If the operation completes successfully, it returns the serial byte array of the NDEF message.
Return value:
byte[] The raw data in the NDEFMessage.Exceptions:
with error type TypeMismatchError, if the records whose type is not NDEFRecord are included in the NDEFMessage.
with error type UnknownError, in any other error case.
Code example:
// Gets the cached message. var cachedMessage = tizen.nfc.getDefaultAdapter().getCachedMessage(); var raw = cachedMessage.toByte();
[Constructor(short tnf, byte[] type, byte[] payload, optional byte[]? id), Constructor(byte[] raw_data)] interface NDEFRecord { readonly attribute short tnf; readonly attribute byte[] type; readonly attribute byte[] id; readonly attribute byte[] payload; };
Since: 2.3.1
NDEFRecord(short tnf, byte[] type, byte[] payload, optional byte[]? id);
NDEFRecord(byte[] raw_data);
At least the following values must be supported:
Since: 2.3.1
The byte array contains 0 to 255 bytes.
Since: 2.3.1
The byte array contains 0 to 255 bytes.
By default, this attribute is set to an empty array.
Since: 2.3.1
The byte array contains 0 to (2 ** 32 - 1) bytes.
Since: 2.3.1
Code example:
// Creates a new NDEF record. var newRecord = new tizen.NDEFRecordURI("https://www.tizen.org/"); var payload = newRecord.payload;
[Constructor(DOMString text, DOMString languageCode, optional DOMString? encoding)] interface NDEFRecordText : NDEFRecord { readonly attribute DOMString text; readonly attribute DOMString languageCode; readonly attribute NDEFRecordTextEncoding encoding; };
Since: 2.3.1
NDEFRecordText(DOMString text, DOMString languageCode, optional DOMString? encoding);
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
[Constructor(DOMString uri)] interface NDEFRecordURI : NDEFRecord { readonly attribute DOMString uri; };
Since: 2.3.1
NDEFRecordURI(DOMString uri);
Since: 2.3.1
[Constructor(DOMString mimeType, byte[] data)] interface NDEFRecordMedia : NDEFRecord { readonly attribute DOMString mimeType; };
Since: 2.3.1
NDEFRecordMedia(DOMString mimeType, byte[] data);
Since: 2.3.1
[NoInterfaceObject] interface HCEEventData { readonly attribute HCEEventType eventType; readonly attribute byte[] apdu; readonly attribute long length; };
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
[NoInterfaceObject] interface AIDData{ readonly attribute SecureElementType type; readonly attribute AID aid; readonly attribute boolean readOnly; };
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
[Callback, NoInterfaceObject] interface NFCTagDetectCallback { void onattach(NFCTag nfcTag); void ondetach(); };
Since: 2.3.1
This callback interface specifies two methods:
It is used in NFCAdapter.setTagListener().
onattach
void onattach(NFCTag nfcTag);
Since: 2.3.1
Parameters:
ondetach
void ondetach();
Since: 2.3.1
[Callback, NoInterfaceObject] interface NFCPeerDetectCallback { void onattach(NFCPeer nfcPeer); void ondetach(); };
Since: 2.3.1
This callback interface specifies two methods:
It is used in NFCAdapter.setPeerListener().
onattach
void onattach(NFCPeer nfcPeer);
Since: 2.3.1
Parameters:
ondetach
void ondetach();
Since: 2.3.1
[Callback=FunctionOnly, NoInterfaceObject] interface NDEFMessageReadCallback { void onsuccess(NDEFMessage ndefMessage); };
Since: 2.3.1
This callback interface specifies a success method with an NDEF message as an input parameter. It is used in asynchronous operations, such as NFCTag.readNDEF() or NFCPeer.setReceiveNDEFListener().
onsuccess
void onsuccess(NDEFMessage ndefMessage);
Since: 2.3.1
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface ByteArraySuccessCallback { void onsuccess(byte[] data); };
Since: 2.3.1
This callback interface specifies a success method, with raw data as an input parameter. It is used in NFCTag.transceive().
[Callback=FunctionOnly, NoInterfaceObject] interface CardEmulationModeChangeCallback { void onchanged(CardEmulationMode mode); };
Since: 2.3.1
onchanged
void onchanged(CardEmulationMode mode);
Since: 2.3.1
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface TransactionEventCallback { void ondetected(octet[] appletId, octet[] data); };
Since: 2.3.1
[Callback=FunctionOnly, NoInterfaceObject] interface ActiveSecureElementChangeCallback { void onchanged(SecureElementType type); };
Since: 2.3.1
onchanged
void onchanged(SecureElementType type);
Since: 2.3.1
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface HCEEventReceiveCallback { void ondetected(HCEEventData data); };
Since: 2.3.1
ondetected
void ondetected(HCEEventData data);
Since: 2.3.1
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface AIDArraySuccessCallback { void onsuccess(AIDData[] aids); };
Since: 2.3.1
onsuccess
void onsuccess(AIDData[] aids);
Since: 2.3.1
Parameters:
To guarantee that the NFC application runs on a device with the NFC feature, declare the following feature requirements in the config file:
To guarantee that the NFC application runs on a device with the NFC tag feature, declare the following feature requirements in the config file:
To guarantee that the NFC application runs on a device with the NFC p2p feature, declare the following feature requirements in the config file:
To guarantee that the NFC card emulation application runs on a device with the NFC card emulation feature, declare the following feature requirements in the config file:
To guarantee that the NFC host-based card emulation application runs on a device with the NFC host-based card emulation feature, declare the following feature requirements in the config file:
module NFC { enum NDEFRecordTextEncoding { "UTF8", "UTF16" }; enum NFCTagType { "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", "UNKNOWN_TARGET" }; enum CardEmulationMode { "ALWAYS_ON", "OFF" }; enum SecureElementType { "ESE", "UICC", "HCE" }; enum CardEmulationCategoryType { "PAYMENT", "OTHER" }; enum HCEEventType { "DEACTIVATED", "ACTIVATED", "APDU_RECEIVED" }; typedef DOMString AID; [NoInterfaceObject] interface NFCManagerObject { readonly attribute NFCManager nfc; }; Tizen implements NFCManagerObject; [NoInterfaceObject] interface NFCManager { const short NFC_RECORD_TNF_EMPTY = 0; const short NFC_RECORD_TNF_WELL_KNOWN = 1; const short NFC_RECORD_TNF_MIME_MEDIA = 2; const short NFC_RECORD_TNF_URI = 3; const short NFC_RECORD_TNF_EXTERNAL_RTD = 4; const short NFC_RECORD_TNF_UNKNOWN = 5; const short NFC_RECORD_TNF_UNCHANGED = 6; NFCAdapter getDefaultAdapter() raises(WebAPIException); void setExclusiveMode(boolean mode) raises(WebAPIException); }; [NoInterfaceObject] interface NFCAdapter { readonly attribute boolean powered; attribute CardEmulationMode cardEmulationMode raises(WebAPIException); attribute SecureElementType? activeSecureElement raises(WebAPIException); void setPowered(boolean state, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void setTagListener(NFCTagDetectCallback detectCallback, optional NFCTagType[]? tagFilter) raises(WebAPIException); void setPeerListener(NFCPeerDetectCallback detectCallback) raises(WebAPIException); void unsetTagListener() raises(WebAPIException); void unsetPeerListener() raises(WebAPIException); long addCardEmulationModeChangeListener(CardEmulationModeChangeCallback changeCallback) raises(WebAPIException); void removeCardEmulationModeChangeListener(long watchId) raises(WebAPIException); long addTransactionEventListener(SecureElementType type, TransactionEventCallback eventCallback) raises(WebAPIException); void removeTransactionEventListener(long watchId) raises(WebAPIException); long addActiveSecureElementChangeListener(ActiveSecureElementChangeCallback changeCallback) raises(WebAPIException); void removeActiveSecureElementChangeListener(long watchId) raises(WebAPIException); NDEFMessage? getCachedMessage() raises(WebAPIException); void setExclusiveModeForTransaction(boolean mode) raises(WebAPIException); long addHCEEventListener(HCEEventReceiveCallback eventCallback) raises(WebAPIException); void removeHCEEventListener(long watchId) raises(WebAPIException); void sendHostAPDUResponse(byte[] apdu, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); boolean isActivatedHandlerForAID(SecureElementType type, AID aid) raises(WebAPIException); boolean isActivatedHandlerForCategory(SecureElementType type, CardEmulationCategoryType category) raises(WebAPIException); void registerAID(SecureElementType type, AID aid, CardEmulationCategoryType category) raises(WebAPIException); void unregisterAID(SecureElementType type, AID aid, CardEmulationCategoryType category) raises(WebAPIException); void getAIDsForCategory(SecureElementType type, CardEmulationCategoryType category, AIDArraySuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [NoInterfaceObject] interface NFCTag { readonly attribute NFCTagType type; readonly attribute boolean isSupportedNDEF; readonly attribute long ndefSize; readonly attribute object properties; readonly attribute boolean isConnected; void readNDEF(NDEFMessageReadCallback readCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void writeNDEF(NDEFMessage ndefMessage, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void transceive(byte[] data, ByteArraySuccessCallback dataCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [NoInterfaceObject] interface NFCPeer { readonly attribute boolean isConnected; void setReceiveNDEFListener(NDEFMessageReadCallback successCallback) raises(WebAPIException); void unsetReceiveNDEFListener() raises(WebAPIException); void sendNDEF(NDEFMessage ndefMessage, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [Constructor(), Constructor(NDEFRecord[] ndefRecords), Constructor(byte[] rawData)] interface NDEFMessage { readonly attribute long recordCount; attribute NDEFRecord[] records; byte[] toByte() raises(WebAPIException); }; [Constructor(short tnf, byte[] type, byte[] payload, optional byte[]? id), Constructor(byte[] raw_data)] interface NDEFRecord { readonly attribute short tnf; readonly attribute byte[] type; readonly attribute byte[] id; readonly attribute byte[] payload; }; [Constructor(DOMString text, DOMString languageCode, optional DOMString? encoding)] interface NDEFRecordText : NDEFRecord { readonly attribute DOMString text; readonly attribute DOMString languageCode; readonly attribute NDEFRecordTextEncoding encoding; }; [Constructor(DOMString uri)] interface NDEFRecordURI : NDEFRecord { readonly attribute DOMString uri; }; [Constructor(DOMString mimeType, byte[] data)] interface NDEFRecordMedia : NDEFRecord { readonly attribute DOMString mimeType; }; [NoInterfaceObject] interface HCEEventData { readonly attribute HCEEventType eventType; readonly attribute byte[] apdu; readonly attribute long length; }; [NoInterfaceObject] interface AIDData{ readonly attribute SecureElementType type; readonly attribute AID aid; readonly attribute boolean readOnly; }; [Callback, NoInterfaceObject] interface NFCTagDetectCallback { void onattach(NFCTag nfcTag); void ondetach(); }; [Callback, NoInterfaceObject] interface NFCPeerDetectCallback { void onattach(NFCPeer nfcPeer); void ondetach(); }; [Callback=FunctionOnly, NoInterfaceObject] interface NDEFMessageReadCallback { void onsuccess(NDEFMessage ndefMessage); }; [Callback=FunctionOnly, NoInterfaceObject] interface ByteArraySuccessCallback { void onsuccess(byte[] data); }; [Callback=FunctionOnly, NoInterfaceObject] interface CardEmulationModeChangeCallback { void onchanged(CardEmulationMode mode); }; [Callback=FunctionOnly, NoInterfaceObject] interface TransactionEventCallback { void ondetected(octet[] appletId, octet[] data); }; [Callback=FunctionOnly, NoInterfaceObject] interface ActiveSecureElementChangeCallback { void onchanged(SecureElementType type); }; [Callback=FunctionOnly, NoInterfaceObject] interface HCEEventReceiveCallback { void ondetected(HCEEventData data); }; [Callback=FunctionOnly, NoInterfaceObject] interface AIDArraySuccessCallback { void onsuccess(AIDData[] aids); }; };