| elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | Yes| Application description, which includes the bundle name and component name.|
| type | [CardType](#cardtype) | Yes| Application description, which includes the bundle name and component name.|
**Return value**
**Return value**
| **Type**| **Description**|
| **Type**| **Description**|
| -------- | -------- |
| -------- | -------- |
| boolean | Returns **true** if the application is the default payment application; returns **false** otherwise.|
| boolean | Returns **true** if HCE is supported; returns **false** otherwise.|
## HceService<sup>8+</sup>
Implements HCE, including receiving Application Protocol Data Units (APDUs) from the peer card reader and sending a response. Before using HCE-related APIs, check whether the device supports HCE.
### startHCE<sup>8+</sup>
startHCE(aidList: string[]): boolean
Starts HCE, including setting the application to be foreground preferred and dynamically registering the application identifier (AID) list.
| type | string | Yes | Event type to subscribe to. The value is **hceCmd**. |
| elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | Yes| Application description, which consists of the bundle name and component name.|
| callback | AsyncCallback<number[]> | Yes | Callback invoked to return the APDU, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| type | [CardType](#cardtype9) | Yes| Card emulation service type.|
| responseApdu | number[] | Yes | Response APDU sent to the peer card reader. The value consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| boolean | Returns **true** if the application is the default payment application; returns **false** otherwise.|
| algName | string | Yes | Digest algorithm. For details about the supported algorithms, see [HMAC Algorithm Specifications](../../security/cryptoFramework-overview.md#hmac-algorithm-specifications).|
| algName | string | Yes | Digest algorithm. For details about the supported algorithms, see [HMAC Algorithm Specifications](../../security/cryptoFramework-overview.md#hmac-algorithm-specifications).|
**Return value**
**Return value**
...
@@ -483,7 +483,7 @@ For details about the supported specifications, see [MD Algorithm Specifications
...
@@ -483,7 +483,7 @@ For details about the supported specifications, see [MD Algorithm Specifications
| algName | string | Yes | Digest algorithm. For details about the supported algorithms, see [MD Algorithm Specifications](../../security/cryptoFramework-overview.md#md-algorithm-specifications).|
| algName | string | Yes | Digest algorithm. For details about the supported algorithms, see [MD Algorithm Specifications](../../security/cryptoFramework-overview.md#md-algorithm-specifications).|
**Return value**
**Return value**
...
@@ -1852,7 +1852,7 @@ Updates the data to encrypt or decrypt by segment. This API uses a promise to re
...
@@ -1852,7 +1852,7 @@ Updates the data to encrypt or decrypt by segment. This API uses a promise to re
@@ -8,7 +8,7 @@ The **relationalStore** module provides the following functions:
...
@@ -8,7 +8,7 @@ The **relationalStore** module provides the following functions:
-[RdbStore](#rdbstore): provides APIs for managing data in an RDB store.
-[RdbStore](#rdbstore): provides APIs for managing data in an RDB store.
-[Resultset](#resultset): provides APIs for accessing the result set obtained from the RDB store.
-[Resultset](#resultset): provides APIs for accessing the result set obtained from the RDB store.
> **NOTE**<br/>
> **NOTE**
>
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...
@@ -30,7 +30,7 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul
...
@@ -30,7 +30,7 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).|
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
| config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. |
| config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. |
| callback | AsyncCallback<[RdbStore](#rdbstore)> | Yes | Callback invoked to return the RDB store obtained. |
| callback | AsyncCallback<[RdbStore](#rdbstore)> | Yes | Callback invoked to return the RDB store obtained. |
...
@@ -108,7 +108,7 @@ Obtains an RDB store. This API uses a promise to return the result. You can set
...
@@ -108,7 +108,7 @@ Obtains an RDB store. This API uses a promise to return the result. You can set
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).|
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
| config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. |
| config | [StoreConfig](#storeconfig) | Yes | Configuration of the RDB store. |
**Return value**
**Return value**
...
@@ -188,7 +188,7 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul
...
@@ -188,7 +188,7 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).|
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
| name | string | Yes | Name of the RDB store to delete. |
| name | string | Yes | Name of the RDB store to delete. |
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. |
...
@@ -249,7 +249,7 @@ Deletes an RDB store. This API uses a promise to return the result.
...
@@ -249,7 +249,7 @@ Deletes an RDB store. This API uses a promise to return the result.
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-ability-context.md).|
| context | Context | Yes | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
| name | string | Yes | Name of the RDB store to delete. |
| name | string | Yes | Name of the RDB store to delete. |
**Return value**
**Return value**
...
@@ -363,6 +363,8 @@ Defines the database synchronization mode.
...
@@ -363,6 +363,8 @@ Defines the database synchronization mode.
@@ -6,6 +6,7 @@ The **fileAccess** module is a framework for accessing and operating user files
...
@@ -6,6 +6,7 @@ The **fileAccess** module is a framework for accessing and operating user files
>
>
>- The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>- The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>- The APIs provided by this module are system APIs and cannot be called by third-party applications. Currently, the APIs can be called only by **FilePicker** and **Files**.
>- The APIs provided by this module are system APIs and cannot be called by third-party applications. Currently, the APIs can be called only by **FilePicker** and **Files**.
>- The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md).
## Modules to Import
## Modules to Import
...
@@ -25,9 +26,9 @@ Obtains information about all wants with **extension** set to **fileAccess** in
...
@@ -25,9 +26,9 @@ Obtains information about all wants with **extension** set to **fileAccess** in
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| --- | -- |
| --- | -- |
| Promise<Array<Want>> | Promise used to return the **want** information obtained.|
| Promise<Array<Want>> | Promise used to return the **want** information obtained.|
**Example**
**Example**
...
@@ -55,9 +56,9 @@ Obtains information about all wants with **extension** set to **fileAccess** in
...
@@ -55,9 +56,9 @@ Obtains information about all wants with **extension** set to **fileAccess** in
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| --- | --- | --- | -- |
| callback | AsyncCallback<Array<Want>> | Yes| Promise used to return the **want** information obtained.|
| callback | AsyncCallback<Array<Want>> | Yes| Promise used to return the **want** information obtained.|
**Example**
**Example**
...
@@ -89,16 +90,16 @@ Synchronously creates a **Helper** object to connect to the specified wants. The
...
@@ -89,16 +90,16 @@ Synchronously creates a **Helper** object to connect to the specified wants. The
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| --- | --- | --- | -- |
| context | Context | Yes| Context of the ability.|
| context | Context | Yes| Context of the ability.|
| wants | Array<Want> | Yes| Wants to connect.|
| wants | Array<Want> | Yes| Wants to connect.|
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| --- | -- |
| --- | -- |
| FileAccessHelper | **Helper** object created.|
| FileAccessHelper | **Helper** object created.|
**Example**
**Example**
...
@@ -136,15 +137,15 @@ Synchronously creates a **Helper** object to connect to all file management serv
...
@@ -136,15 +137,15 @@ Synchronously creates a **Helper** object to connect to all file management serv
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| --- | --- | --- | -- |
| context | Context | Yes| Context of the ability.|
| context | Context | Yes| Context of the ability.|
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| --- | -- |
| --- | -- |
| FileAccessHelper | **Helper** object created.|
| FileAccessHelper | **Helper** object created.|
**Example**
**Example**
...
@@ -175,9 +176,9 @@ Obtains information about the device root nodes of the file management service t
...
@@ -175,9 +176,9 @@ Obtains information about the device root nodes of the file management service t
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| --- | -- |
| --- | -- |
| Promise<RootIterator> | Promise used to return the **RootIterator** object obtained.|
| Promise<RootIterator> | Promise used to return the **RootIterator** object obtained.|
**Example**
**Example**
...
@@ -220,9 +221,9 @@ The callback has a **RootIterator** object, which returns [RootInfo](#rootinfo)
...
@@ -220,9 +221,9 @@ The callback has a **RootIterator** object, which returns [RootInfo](#rootinfo)
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| --- | --- | --- | -- |
| --- | --- | --- | -- |
| callback | AsyncCallback<RootIterator> | Yes| Promise used to return the **RootIterator** object obtained.|
| callback | AsyncCallback<RootIterator> | Yes| Promise used to return the **RootIterator** object obtained.|
**Example**
**Example**
...
@@ -263,16 +264,16 @@ Synchronously obtains the **FileIterator** object of the first-level files (dire
...
@@ -263,16 +264,16 @@ Synchronously obtains the **FileIterator** object of the first-level files (dire
The **nfcController** module provides APIs for opening and closing Near-Field Communication (NFC) and reading the NFC state.
The **nfcController** module provides APIs for opening and closing Near-Field Communication (NFC) and reading the NFC state.
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use canIUse("SystemCapability.Communication.NFC.Core").
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
Obtains the **tagInfo** object provided by the NFC service when the tag is dispatched.
Obtains the **tagInfo** object provided by the NFC service when the tag is dispatched.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tag.getTagInfo](js-apis-nfcTag.md#taggettaginfo9).
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error message|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
**Example**
```js
importtagfrom'@ohos.nfc.tag';
// tagInfo is an object provided by the NFC service when a tag is dispatched.
// getXXX can be getIsoDep, getNdef, getMifareClassic, or any other getter for NFC tags.
try{
tag.getIsoDep(tagInfo).connect();
console.log("tag connect success");
}catch(busiError){
console.log("tag connect busiError: "+busiError);
}
```
### tagSession.reset()
### tagSession.reset()
reset(): void
reset(): void
Resets the connection to this tag.
Resets the connection to this tag.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.resetConnection](#tagsessionresetconnection9).
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.isConnected](#tagsessionisconnected9).
Obtains the maximum length of the data that can be sent to this tag.
Obtains the maximum length of the data that can be sent to this tag.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.getMaxTransmitSize](#tagsessiongetmaxtransmitsize9).
Obtains the timeout period for sending data to this tag, in milliseconds.
Obtains the timeout period for sending data to this tag, in milliseconds.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.getTimeout](#tagsessiongettimeout9).
Sets the timeout period for sending data to this tag, in milliseconds.
Sets the timeout period for sending data to this tag, in milliseconds.
> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tagSession.setTimeout](#tagsessionsettimeout9).
Sends data to this tag. This API uses an asynchronous callback to return the result.
Sends data to this tag. This API uses an asynchronous callback to return the result.
> **NOTE**
> This parameter is supported since API version 7 and discarded since API version 9. You are advised to use [tagSession.transmit](#tagsessiontransmit9-1).
| Promise<number[]> | Promise used to return the response from the tag. The response consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error message|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
**Example**
```js
importtagfrom'@ohos.nfc.tag';
// tagInfo is an object provided by the NFC service when a tag is dispatched.
// getXXX can be getIsoDep, getNdef, getMifareClassic, or any other getter for NFC tags.
// Connect to the tag if it is not connected.
try{
if(!tag.getIsoDep(tagInfo).isConnected()){
tag.getIsoDep(tagInfo).connect();
}
}catch(busiError){
console.log("tag connect busiError: "+busiError);
return;
}
letcmdData=[0x01,0x02,0x03,0x04];// Change it as required.
| data | number[] | Yes| Data to send. The data consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| callback | AsyncCallback<number[]> | Yes| Callback invoked to return the response from the tag. The response consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error message|
| ------- | -------|
| 3100201 | Tag running state is abnormal in service. |
**Example**
```js
importtagfrom'@ohos.nfc.tag';
// tagInfo is an object provided by the NFC service when a tag is dispatched.
// getXXX can be getIsoDep, getNdef, getMifareClassic, or any other getter for NFC tags.
// Connect to the tag if it is not connected.
try{
if(!tag.getIsoDep(tagInfo).isConnected()){
tag.getIsoDep(tagInfo).connect();
}
}catch(busiError){
console.log("tag connect busiError: "+busiError);
return;
}
letcmdData=[0x01,0x02,0x03,0x04];// Change it as required.
# Changelog of NFC JS APIs in the Communication Subsystem
Compared with OpenHarmony 3.2 Beta4, OpenHarmony 3.2.10.2(Mr) has the following changes in NFC APIs:
## cl.nfc.1 API Change
Deprecated some NFC JS APIs in API versions 6 to 8 because the APIs cannot throw error codes, and added new APIs in API version 9 instead.
You need to adapt your application.
**Change Impact**
The deprecated JS APIs in API versions 6 to 8 are affected. Your application needs to adapt new APIs so that it can properly implement functions in the SDK environment of the new version.
**Key API/Component Changes**
| Module | Class | Method/Attribute/Enum/Constant | Change Type|