diff --git a/en/application-dev/reference/apis/js-apis-cardEmulation.md b/en/application-dev/reference/apis/js-apis-cardEmulation.md index bd1a79344869a57653984122a12da3826ee98327..b306ac2ed56747cae1d6924706cc97815bd20c93 100644 --- a/en/application-dev/reference/apis/js-apis-cardEmulation.md +++ b/en/application-dev/reference/apis/js-apis-cardEmulation.md @@ -16,31 +16,37 @@ import cardEmulation from '@ohos.nfc.cardEmulation'; Enumerates the NFC card emulation types. +> **NOTE** +> This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [hasHceCapability](#hashcecapability9). + **System capability**: SystemCapability.Communication.NFC.CardEmulation | Name| Value| Description| | -------- | -------- | -------- | | HCE | 0 | HCE.| | UICC | 1 | Subscriber identity module (SIM) card emulation.| -| ESE | 2 | embedded Secure Element (eSE) emulation.| +| ESE | 2 | embedded Secure Element (eSE) emulation.| -## CardType +## CardType9+ -Enumerates the card emulation application types. +Enumerates the types of services used by the card emulation application. **System capability**: SystemCapability.Communication.NFC.CardEmulation | Name| Value| Description| | -------- | -------- | -------- | | PAYMENT | "payment" | Payment type.| -| OTHER | "other" | Other types. | +| OTHER | "other" | Other types.| -## cardEmulation.isSupported +## isSupported isSupported(feature: number): boolean Checks whether a certain type of card emulation is supported. +> **NOTE** +> This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [hasHceCapability](#hashcecapability9). + **System capability**: SystemCapability.Communication.NFC.CardEmulation **Parameters** @@ -55,89 +61,44 @@ Checks whether a certain type of card emulation is supported. | -------- | -------- | | boolean | Returns **true** if the card emulation type is supported; returns **false** otherwise.| -## cardEmulation.isDefaultService +## hasHceCapability9+ -isDefaultService(elementName: ElementName, type: CardType): boolean +hasHceCapability(): boolean -Checks whether the specified application is of the default payment type. +Checks whether HCE is supported. **System capability**: SystemCapability.Communication.NFC.CardEmulation -**Parameters** - -| Name | Type | Mandatory| Description | -| ------- | -------- | ---- | ----------------------- | -| 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.| +**Required permissions**: ohos.permission.NFC_CARD_EMULATION **Return value** | **Type**| **Description**| | -------- | -------- | -| boolean | Returns **true** if the application is the default payment application; returns **false** otherwise.| - -## HceService8+ +| boolean | Returns **true** if HCE is supported; returns **false** otherwise.| -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. +## isDefaultService9+ -### startHCE8+ +isDefaultService(elementName: ElementName, type: CardType): boolean -startHCE(aidList: string[]): boolean +Checks whether an application is the default application of the specified service type. -Starts HCE, including setting the application to be foreground preferred and dynamically registering the application identifier (AID) list. +**System capability**: SystemCapability.Communication.NFC.CardEmulation **Required permissions**: ohos.permission.NFC_CARD_EMULATION -**System capability**: SystemCapability.Communication.NFC.CardEmulation - **Parameters** | Name | Type | Mandatory| Description | | ------- | -------- | ---- | ----------------------- | -| aidList | string[] | Yes | AID list to register.| - -### stopHCE8+ - -stopHCE(): boolean - -Stops HCE, including removing the foreground preferred attribute and releasing the dynamically registered AID list. - -**Required permissions**: ohos.permission.NFC_CARD_EMULATION - -**System capability**: SystemCapability.Communication.NFC.CardEmulation - -### on8+ - -on(type: "hceCmd", callback: AsyncCallback): void; +| elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | Yes| Application description, which consists of the bundle name and component name.| +| type | [CardType](#cardtype9) | Yes| Card emulation service type.| -Registers a callback to receive APDUs from the peer card reader. - -**Required permissions**: ohos.permission.NFC_CARD_EMULATION - -**System capability**: SystemCapability.Communication.NFC.CardEmulation - -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | -------------------------------------------- | -| type | string | Yes | Event type to subscribe to. The value is **hceCmd**. | -| callback | AsyncCallback | Yes | Callback invoked to return the APDU, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| - -### sendResponse8+ - -sendResponse(responseApdu: number[]): void; - -Sends a response to the peer card reader. - -**Required permissions**: ohos.permission.NFC_CARD_EMULATION - -**System capability**: SystemCapability.Communication.NFC.CardEmulation - -**Parameters** +**Return value** -| Name | Type | Mandatory| Description | -| ------------ | -------- | ---- | -------------------------------------------------- | -| responseApdu | number[] | Yes | Response APDU sent to the peer card reader. The value consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| +| **Type**| **Description**| +| -------- | -------- | +| boolean | Returns **true** if the application is the default payment application; returns **false** otherwise.| **Example** @@ -150,30 +111,16 @@ if (!isHceSupported) { return; } +var hasHceCap = cardEmulation.hasHceCapability(); +if (!hasHceCap) { + console.log('this device hasHceCapability false, ignore it.'); + return; +} + var elementName = { "bundleName": "com.test.cardemulation", "abilityName": "com.test.cardemulation.MainAbility", }; var isDefaultService = cardEmulation.isDefaultService(elementName, cardEmulation.CardType.PAYMENT); console.log('is the app is default service for this card type: ' + isDefaultService); - -// The device supports HCE and transimits APDUs with the remote NFC reader. -var hceService = new cardEmulation.HceService(); -hceService.startHCE([ - "F0010203040506", "A0000000041010" -]); - -hceService.on("hceCmd", (err, res) => { - if(err.data === 0) { - console.log('callback => Operation hceCmd succeeded. Data: ' + JSON.stringify(res)); - hceService.sendResponse([0x00,0xa4,0x04,0x00, - 0x0e,0x32,0x50,0x41,0x59,0x2e,0x53,0x59,0x53,0x2e,0x44,0x44, - 0x46,0x30,0x31,0x00]); - } else { - console.log('callback => Operation hceCmd failed. Cause: ' + err.data); - } -}) - -// stop HCE when the application exit the nfc card emulation. -hceService.stopHCE(); ``` diff --git a/en/application-dev/reference/apis/js-apis-data-relationalStore.md b/en/application-dev/reference/apis/js-apis-data-relationalStore.md index d2afe1626ac0b84e695ce9f3b3d12010c0ff6060..d3f7ca70fe6ae50eed829fa54ff783622590497f 100644 --- a/en/application-dev/reference/apis/js-apis-data-relationalStore.md +++ b/en/application-dev/reference/apis/js-apis-data-relationalStore.md @@ -8,7 +8,7 @@ The **relationalStore** module provides the following functions: - [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. -> **NOTE**
+> **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. @@ -30,7 +30,7 @@ Obtains an RDB store. This API uses an asynchronous callback to return the resul | Name | Type | Mandatory| Description | | -------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
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. | | 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 | Name | Type | Mandatory| Description | | ------- | -------------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
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. | **Return value** @@ -188,7 +188,7 @@ Deletes an RDB store. This API uses an asynchronous callback to return the resul | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
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. | | 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. | Name | Type | Mandatory| Description | | ------- | ------- | ---- | ------------------------------------------------------------ | -| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
For details about the application context of the stage model, see [Context](js-apis-ability-context.md).| +| context | Context | Yes | Application context.
For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).
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. | **Return value** @@ -2430,9 +2430,9 @@ Synchronizes data between devices. This API uses a promise to return the result. let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); predicates.inDevices(['12345678abcde']); let promise = store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates); -promise.then((resultSet) =>{ +promise.then((result) =>{ console.info(`Sync done.`); - for (let i = 0; i < resultSet.length; i++) { + for (let i = 0; i < result.length; i++) { console.info(`device= ${result[i][0]}, status= ${result[i][1]}`); } }).catch((err) => { @@ -2511,10 +2511,12 @@ Provides APIs to access the result set obtained by querying the RDB store. A res Obtain the **resultSet** object first. ```js +let resultSet = null; let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); predicates.equalTo("AGE", 18); let promise = store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); -promise.then((resultSet) => { +promise.then((result) => { + resultSet = result; console.info(`resultSet columnNames: ${resultSet.columnNames}`); console.info(`resultSet columnCount: ${resultSet.columnCount}`); }); @@ -2685,7 +2687,7 @@ For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); let promise = store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]); promise.then((resultSet) => { - resultSet.(5); + resultSet.goToRow(5); resultSet.close(); }).catch((err) => { console.error(`query failed, err: ${err}`); diff --git a/en/application-dev/reference/apis/js-apis-nfcController.md b/en/application-dev/reference/apis/js-apis-nfcController.md index 105af3cf95ca3a052faddbb6fe632940169fbcd1..9381cdcdbae18cedf6ca6814c3df141e509062d1 100644 --- a/en/application-dev/reference/apis/js-apis-nfcController.md +++ b/en/application-dev/reference/apis/js-apis-nfcController.md @@ -1,14 +1,14 @@ -# Standard NFC +# @ohos.nfc.controller (Standard NFC) The **nfcController** module provides APIs for opening and closing Near-Field Communication (NFC) and reading the NFC state. -> **NOTE**
+> **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. - ## **Modules to Import** -``` +```js import controller from '@ohos.nfc.controller'; ``` @@ -18,7 +18,7 @@ Enumerates the NFC states. **System capability**: SystemCapability.Communication.NFC.Core -| Name| Default Value| Description| +| Name| Value| Description| | -------- | -------- | -------- | | STATE_OFF | 1 | NFC is closed (OFF).| | STATE_TURNING_ON | 2 | NFC is turning on.| @@ -31,6 +31,9 @@ isNfcAvailable(): boolean Checks whether the device supports NFC. +> **NOTE** +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use canIUse("SystemCapability.Communication.NFC.Core"). + **System capability**: SystemCapability.Communication.NFC.Core **Return value** @@ -46,6 +49,9 @@ openNfc(): boolean Opens NFC. +> **NOTE** +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [enableNfc](#controllerenablenfc9). + **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS **System capability**: SystemCapability.Communication.NFC.Core @@ -56,12 +62,33 @@ Opens NFC. | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +## controller.enableNfc9+ + +enableNfc(): boolean + +Opens NFC. + +**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS + +**System capability**: SystemCapability.Communication.NFC.Core + +**Error codes** + +For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). + +| ID| Error Message| +| ------- | -------| +| 3100101 | NFC state is abnormal in service. | + ## controller.closeNfc closeNfc(): boolean Closes NFC. +> **NOTE** +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [disableNfc](#controllerdisablenfc9). + **Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS **System capability**: SystemCapability.Communication.NFC.Core @@ -72,6 +99,24 @@ Closes NFC. | -------- | ------------------------------------------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +## controller.disableNfc9+ + +disableNfc(): boolean + +Closes NFC. + +**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS + +**System capability**: SystemCapability.Communication.NFC.Core + +**Error codes** + +For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md). + +| ID| Error Message| +| ------- | -------| +| 3100101 | NFC state is abnormal in service. | + ## controller.isNfcOpen isNfcOpen(): boolean @@ -108,14 +153,12 @@ Subscribes to NFC state changes. A callback will be invoked to return the NFC st **System capability**: SystemCapability.Communication.NFC.Core -**Parameter** +**Parameters** - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type to subscribe to. The value is **nfcStateChange**.| - | callback | Callback<[NfcState](#nfcstate)> | Yes| Callback invoked to return the NFC state.| - - +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type to subscribe to. The value is **nfcStateChange**.| +| callback | Callback<[NfcState](#nfcstate)> | Yes| Callback invoked to return the NFC state.| ## controller.off('nfcStateChange') @@ -125,42 +168,55 @@ Unsubscribes from the NFC state changes. The subscriber will not receive NFC sta **System capability**: SystemCapability.Communication.NFC.Core -**Parameter** - - | **Name**| **Type**| **Mandatory**| **Description**| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type to unsubscribe from. The value is **nfcStateChange**.| +**Parameters** + +| **Name**| **Type**| **Mandatory**| **Description**| +| -------- | -------- | -------- | -------- | +| type | string | Yes| Event type to unsubscribe from. The value is **nfcStateChange**.| | callback | Callback<[NfcState](#nfcstate)> | No| Callback for the NFC state changes. This parameter can be left blank.| **Example** - ```js - import controller from '@ohos.nfc.controller'; - - // Define a callback key. - var NFC_STATE_CALLBACK_KEY = "nfcStateChange"; - - // Register the callback to receive NFC state change notifications. - controller.on(NFC_STATE_CALLBACK_KEY, (err, nfcState)=> { - if (err) { - console.log("controller on callback err: " + err); - } else { - console.log("controller on callback nfcState: " + nfcState); - } - }); - - // Open NFC. Require permission: ohos.permission.MANAGE_SECURE_SETTINGS. - if (!controller.isNfcOpen()) { - var ret = controller.openNfc(); - console.log("controller openNfc ret: " + ret); - } +```js +import controller from '@ohos.nfc.controller'; - // Close NFC. Require permission: ohos.permission.MANAGE_SECURE_SETTINGS. - if (controller.isNfcOpen()) { - var ret = controller.closeNfc(); - console.log("controller closeNfc ret: " + ret); +// Register the callback to receive NFC state change notifications. +controller.on("nfcStateChange", (err, nfcState)=> { + if (err) { + console.log("controller on callback err: " + err); + } else { + console.log("controller on callback nfcState: " + nfcState); } +}); - // Unregister the callback. - controller.off(NFC_STATE_CALLBACK_KEY); - ``` + // Open NFC. Require permission: ohos.permission.MANAGE_SECURE_SETTINGS. +if (!controller.isNfcOpen()) { + var ret = controller.openNfc(); + console.log("controller openNfc ret: " + ret); +} + +// Use 'enableNfc' to enable NFC from API version 9. +try { + controller.enableNfc(); + console.log("controller enableNfc success"); +} catch (busiError) { + console.log("controller enableNfc busiError: " + busiError); +} + +// Close NFC. Require permission: ohos.permission.MANAGE_SECURE_SETTINGS. +if (controller.isNfcOpen()) { + var ret = controller.closeNfc(); + console.log("controller closeNfc ret: " + ret); +} + +// Use 'disableNfc' to disable NFC from API version 9. +try { + controller.disableNfc(); + console.log("controller disableNfc success"); +} catch (busiError) { + console.log("controller disableNfc busiError: " + busiError); +} + +// Unregister the callback. +controller.off("nfcStateChange"); +``` diff --git a/en/application-dev/reference/apis/js-apis-nfcTag.md b/en/application-dev/reference/apis/js-apis-nfcTag.md index ead2c9bc9653f591b4521588f6f3215782cd4e7a..2dbf451d5202e7d7f7139cfb930007763732eade 100644 --- a/en/application-dev/reference/apis/js-apis-nfcTag.md +++ b/en/application-dev/reference/apis/js-apis-nfcTag.md @@ -73,7 +73,7 @@ onCreate(want, launchParam) { try { tagInfo = tag.getTagInfo(want); } catch (error) { - console.log("tag.getTagInfo catched error: " + error); + console.log("tag.getTagInfo caught error: " + error); } if (tagInfo == null || tagInfo == undefined) { console.log("no TagInfo to be created, ignore it."); @@ -100,7 +100,7 @@ onCreate(want, launchParam) { try { nfcA = tag.getNfcATag(taginfo); } catch (error) { - console.log("tag.getNfcATag catched error: " + error); + console.log("tag.getNfcATag caught error: " + error); } // Other code to read or write this tag. } @@ -111,7 +111,7 @@ onCreate(want, launchParam) { try { isoDep = tag.getIsoDep(taginfo); } catch (error) { - console.log("tag.getIsoDep catched error: " + error); + console.log("tag.getIsoDep caught error: " + error); } // Other code to read or write this tag. } @@ -126,64 +126,204 @@ getNfcATag(tagInfo: [TagInfo](#taginfo)): [NfcATag](js-apis-nfctech.md#nfcatag) Obtains an **NfcATag** object, which allows access to the tags that use the NFC-A technology. -**Required permissions**: ohos.permission.NFC_TAG +> **NOTE** +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tag.getNfcA](#taggetnfca9). + +**System capability**: SystemCapability.Communication.NFC.Tag + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. + +**Return value** + +| **Type**| **Description**| +| -------- | -------- | +| [NfcATag](js-apis-nfctech.md#nfcatag) | **NfcATag** object obtained.| + +## tag.getNfcA9+ + +getNfcA(tagInfo: [TagInfo](#taginfo)): [NfcATag](js-apis-nfctech.md#nfcatag) + +Obtains an **NfcATag** object, which allows access to the tags that use the NFC-A technology. **System capability**: SystemCapability.Communication.NFC.Tag +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. + **Return value** | **Type**| **Description**| | -------- | -------- | | [NfcATag](js-apis-nfctech.md#nfcatag) | **NfcATag** object obtained.| +**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. | + ## tag.getNfcBTag getNfcBTag(tagInfo: [TagInfo](#taginfo)): [NfcBTag](js-apis-nfctech.md#nfcbtag) Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-B technology. -**Required permissions**: ohos.permission.NFC_TAG +> **NOTE** +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tag.getNfcB](#taggetnfcb9). + +**System capability**: SystemCapability.Communication.NFC.Tag + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. + +**Return value** + +| **Type**| **Description** | +| -------- | ---------------- | +| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.| + +## tag.getNfcB9+ + +getNfcB(tagInfo: [TagInfo](#taginfo)): [NfcBTag](js-apis-nfctech.md#nfcbtag) + +Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-B technology. **System capability**: SystemCapability.Communication.NFC.Tag +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. + **Return value** | **Type**| **Description** | | -------- | ---------------- | | [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.| +**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. | + ## tag.getNfcFTag getNfcFTag(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag) Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-F technology. -**Required permissions**: ohos.permission.NFC_TAG +> **NOTE** +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tag.getNfcF](#taggetnfcf9). + +**System capability**: SystemCapability.Communication.NFC.Tag + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. + +**Return value** + +| **Type**| **Description** | +| -------- | ---------------- | +| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.| + +## tag.getNfcF9+ + +getNfcF(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag) + +Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-F technology. **System capability**: SystemCapability.Communication.NFC.Tag +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. + **Return value** | **Type**| **Description** | | -------- | ---------------- | | [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.| +**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. | + ## tag.getNfcVTag getNfcVTag(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag) Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-V technology. -**Required permissions**: ohos.permission.NFC_TAG +> **NOTE** +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [tag.getNfcV](#taggetnfcv9). + +**System capability**: SystemCapability.Communication.NFC.Tag + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. + +**Return value** + +| **Type**| **Description** | +| -------- | ---------------- | +| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.| + +## tag.getNfcV9+ + +getNfcV(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag) + +Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-V technology. **System capability**: SystemCapability.Communication.NFC.Tag +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. + **Return value** | **Type**| **Description** | | -------- | ---------------- | | [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.| +**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. | + ## tag.getIsoDep9+ getIsoDep(tagInfo: [TagInfo](#taginfo)): [IsoDepTag](js-apis-nfctech.md#isoDepTag9 ) diff --git a/en/application-dev/reference/apis/js-apis-nfctech.md b/en/application-dev/reference/apis/js-apis-nfctech.md index c3a4a8858d84aae84f905d5beb9b21a557324344..49d4d31f3bfe67c400d473e0068297fc0bfff4d6 100644 --- a/en/application-dev/reference/apis/js-apis-nfctech.md +++ b/en/application-dev/reference/apis/js-apis-nfctech.md @@ -26,8 +26,6 @@ getSak(): number Obtains the SAK value of this NFC-A tag. -**Required permissions**: ohos.permission.NFC_TAG - **System capability**: SystemCapability.Communication.NFC.Tag **Return value** @@ -52,8 +50,6 @@ getAtqa(): number[] Obtains the ATQA value of this NFC-A tag. -**Required permissions**: ohos.permission.NFC_TAG - **System capability**: SystemCapability.Communication.NFC.Tag **Return value** @@ -86,8 +82,6 @@ getRespAppData(): number[] Obtains the application data of this NFC-B tag. -**Required permissions**: ohos.permission.NFC_TAG - **System capability**: SystemCapability.Communication.NFC.Tag **Return value** @@ -112,8 +106,6 @@ getRespProtocol(): number[] Obtains the protocol information of this NFC-B tag. -**Required permissions**: ohos.permission.NFC_TAG - **System capability**: SystemCapability.Communication.NFC.Tag **Return value** @@ -146,8 +138,6 @@ getSystemCode(): number[] Obtains the system code from this NFC-F tag. -**Required permissions**: ohos.permission.NFC_TAG - **System capability**: SystemCapability.Communication.NFC.Tag **Return value** @@ -172,8 +162,6 @@ getPmm(): number[] Obtains the PMm (consisting of the IC code and manufacturer parameters) information from this NFC-F tag. -**Required permissions**: ohos.permission.NFC_TAG - **System capability**: SystemCapability.Communication.NFC.Tag **Return value** @@ -206,8 +194,6 @@ getResponseFlags(): number Obtains the response flags from this NFC-V tag. -**Required permissions**: ohos.permission.NFC_TAG - **System capability**: SystemCapability.Communication.NFC.Tag **Return value** @@ -232,8 +218,6 @@ getDsfId(): number Obtains the data storage format identifier (DSFID) from this NFC-V tag. -**Required permissions**: ohos.permission.NFC_TAG - **System capability**: SystemCapability.Communication.NFC.Tag **Return value** diff --git a/en/application-dev/reference/errorcodes/errorcode-nfc.md b/en/application-dev/reference/errorcodes/errorcode-nfc.md index 500d870366c8a88a9036454ada2d0ffe0a3c04a9..4169a40d6388d0883088621e0dba243f0c6d050f 100644 --- a/en/application-dev/reference/errorcodes/errorcode-nfc.md +++ b/en/application-dev/reference/errorcodes/errorcode-nfc.md @@ -4,7 +4,7 @@ **Error Message** -NFC opening or closing state is abnormal in service. +NFC state is abnormal in service. **Description** @@ -12,11 +12,13 @@ The NFC service fails to enable or disable NFC. **Possible Causes** -Communication with the NFC service failed. +1. Communication with the NFC service failed. +2. The NFC chip communication is abnormal. **Solution** -Enable or disable NFC again. +1. Enable or disable NFC again. +2. Enable or disable NFC again or restart the device, and try again. ## 3100201 @@ -30,7 +32,7 @@ An error occurs when the NFC service executes the tag service logic. **Possible Causes** 1. The tag parameters do not match the API to invoke. -2. The NFC is disabled. +2. NFC is disabled. 3. The tag is disconnected before the tag operation. 4. The tag chip returns an error status or response timeout. 5. Binding with the NFC service has not been established. diff --git a/en/release-notes/changelogs/OpenHarmony_3.2.10.3/changelogs-nfc.md b/en/release-notes/changelogs/OpenHarmony_3.2.10.3/changelogs-nfc.md new file mode 100644 index 0000000000000000000000000000000000000000..b4cccb7e0e18556fcda82b4733daf7f16ffbc846 --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_3.2.10.3/changelogs-nfc.md @@ -0,0 +1,61 @@ +# 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| +| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- | +| api/@ohos.nfc.cardEmulation.d.ts | cardEmulation | FeatureType | Deprecated | +| api/@ohos.nfc.cardEmulation.d.ts | cardEmulation | isSupported | Deprecated | +| api/@ohos.nfc.cardEmulation.d.ts | cardEmulation | hasHceCapability | Added | +| api/@ohos.nfc.controller.d.ts | nfcController | isNfcAvailable | Deprecated | +| api/@ohos.nfc.controller.d.ts | nfcController | openNfc | Deprecated | +| api/@ohos.nfc.controller.d.ts | nfcController | closeNfc | Deprecated | +| api/@ohos.nfc.controller.d.ts | nfcController | enableNfc | Added | +| api/@ohos.nfc.controller.d.ts | nfcController | disableNfc | Added | +| api/@ohos.nfc.tag.d.ts | tag | getNfcATag | Deprecated | +| api/@ohos.nfc.tag.d.ts | tag | getNfcBTag | Deprecated | +| api/@ohos.nfc.tag.d.ts | tag | getNfcFTag | Deprecated | +| api/@ohos.nfc.tag.d.ts | tag | getNfcVTag | Deprecated | +| api/@ohos.nfc.tag.d.ts | tag | getNfcA | Added | +| api/@ohos.nfc.tag.d.ts | tag | getNfcB | Added | +| api/@ohos.nfc.tag.d.ts | tag | getNfcF | Added | +| api/@ohos.nfc.tag.d.ts | tag | getNfcV | Added | +| api/tag/tagSession.d.ts | TagSession | getTagInfo | Deprecated | +| api/tag/tagSession.d.ts | TagSession | connectTag | Deprecated | +| api/tag/tagSession.d.ts | TagSession | reset | Deprecated | +| api/tag/tagSession.d.ts | TagSession | isTagConnected | Deprecated | +| api/tag/tagSession.d.ts | TagSession | setSendDataTimeout | Deprecated | +| api/tag/tagSession.d.ts | TagSession | getSendDataTimeout | Deprecated | +| api/tag/tagSession.d.ts | TagSession | sendData | Deprecated | +| api/tag/tagSession.d.ts | TagSession | getMaxSendLength | Deprecated | +| api/tag/tagSession.d.ts | TagSession | connect | Added | +| api/tag/tagSession.d.ts | TagSession | resetConnection | Added | +| api/tag/tagSession.d.ts | TagSession | isConnected | Added | +| api/tag/tagSession.d.ts | TagSession | setTimeout | Added | +| api/tag/tagSession.d.ts | TagSession | getTimeout | Added | +| api/tag/tagSession.d.ts | TagSession | transmit | Added | +| api/tag/tagSession.d.ts | TagSession | getMaxTransmitSize | Added | + +**Adaptation Guide** + +See the following: +[@ohos.nfc.cardEmulation (Standard NFC Card Emulation)](../../../application-dev/reference/apis/js-apis-cardEmulation.md) + +[@ohos.nfc.controller (Standard NFC)](../../../application-dev/reference/apis/js-apis-nfcController.md) + +[@ohos.nfc.tag (Standard NFC Tags)](../../../application-dev/reference/apis/js-apis-nfcTag.md) + +[tagSession (Standard NFC Tag Session)](../../../application-dev/reference/apis/js-apis-tagSession.md) + +