From f06ef6027b8b2d17ef196492692c79d9fa85b61e Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Mon, 17 Jul 2023 21:15:27 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../reference/apis/js-apis-nfcTag.md | 479 ++++++++-------- .../reference/apis/js-apis-secureElement.md | 540 +++++++++--------- .../reference/apis/js-apis-system-storage.md | 25 +- 3 files changed, 512 insertions(+), 532 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-nfcTag.md b/en/application-dev/reference/apis/js-apis-nfcTag.md index aec61516c4..2a9f991714 100644 --- a/en/application-dev/reference/apis/js-apis-nfcTag.md +++ b/en/application-dev/reference/apis/js-apis-nfcTag.md @@ -34,7 +34,7 @@ Before developing applications related to tag read and write, you must declare N { "name": "tag-tech", "value": "IsoDep" - }, + } // Add other technologies, // such as NfcB, NfcF, NfcV, Ndef, MifareClassic, MifareUL, and NdefFormatable. ] @@ -67,59 +67,61 @@ import tag from '@ohos.nfc.tag'; Before a card with tags is read or written, **TagInfo** must be obtained to determine the tag technologies supported by the card. In this way, the application can invoke the correct API to communicate with the card. ```js import tag from '@ohos.nfc.tag'; +import UIAbility from '@ohos.app.ability.UIAbility'; -onCreate(want, launchParam) { +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { // Add other code here. - // want is initialized by the NFC service and contains tagInfo. - var tagInfo; - try { - tagInfo = tag.getTagInfo(want); - } catch (error) { - console.log("tag.getTagInfo caught error: " + error); - } - if (tagInfo == null || tagInfo == undefined) { - console.log("no TagInfo to be created, ignore it."); - return; - } - - // get the supported technologies for this found tag. - var isNfcATag = false; - var isIsoDepTag = false; - for (var i = 0; i < tagInfo.technology.length; i++) { - if (tagInfo.technology[i] == tag.NFC_A) { - isNfcATag = true; + // want is initialized by the NFC service and contains tagInfo. + var tagInfo; + try { + tagInfo = tag.getTagInfo(want); + } catch (error) { + console.log("tag.getTagInfo caught error: " + error); } - - if (tagInfo.technology[i] == tag.ISO_DEP) { - isIsoDepTag = true; + if (tagInfo == null || tagInfo == undefined) { + console.log("no TagInfo to be created, ignore it."); + return; } + + // get the supported technologies for this found tag. + var isNfcATag = false; + var isIsoDepTag = false; + for (var i = 0; i < tagInfo.technology.length; i++) { + if (tagInfo.technology[i] == tag.NFC_A) { + isNfcATag = true; + } + + if (tagInfo.technology[i] == tag.ISO_DEP) { + isIsoDepTag = true; + } // Also check for technology tag.NFC_B, NFC_F, NFC_V, ISO_DEP, NDEF, MIFARE_CLASSIC, MIFARE_ULTRALIGHT, and NDEF_FORMATABLE. - } + } - // use NfcA APIs to access the found tag. - if (isNfcATag) { - var nfcA; - try { - nfcA = tag.getNfcATag(tagInfo); - } catch (error) { - console.log("tag.getNfcATag caught error: " + error); + // use NfcA APIs to access the found tag. + if (isNfcATag) { + var nfcA; + try { + nfcA = tag.getNfcATag(tagInfo); + } catch (error) { + console.log("tag.getNfcATag caught error: " + error); + } + // Other code to read or write this tag. } - // Other code to read or write this tag. - } - // use getIsoDep APIs to access the found tag. - if (isIsoDepTag) { - var isoDep; - try { - isoDep = tag.getIsoDep(tagInfo); - } catch (error) { - console.log("tag.getIsoDep caught error: " + error); + // use getIsoDep APIs to access the found tag. + if (isIsoDepTag) { + var isoDep; + try { + isoDep = tag.getIsoDep(tagInfo); + } catch (error) { + console.log("tag.getIsoDep caught error: " + error); + } + // Other code to read or write this tag. } - // Other code to read or write this tag. + // Use the same code to handle "NfcA/NfcB/NfcF/NfcV/Ndef/MifareClassic/MifareUL/NdefFormatable". } - - // Use the same code to handle "NfcA/NfcB/NfcF/NfcV/Ndef/MifareClassic/MifareUL/NdefFormatable". } ``` @@ -136,14 +138,14 @@ Obtains an **NfcATag** object, which allows access to the tags that use the NFC- **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)**. +| 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** | -| ------------------------------------- | ------------- | +| **Type** | **Description** | +| ------------------------------------- | ------------------ | | [NfcATag](js-apis-nfctech.md#nfcatag) | **NfcATag** object obtained.| ## tag.getNfcA9+ @@ -156,23 +158,23 @@ Obtains an **NfcATag** object, which allows access to the tags that use the NFC- **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)**. +| 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** | -| ------------------------------------- | ------------- | +| **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. | +| ID| Error Message | +| -------- | ----------------------------------------- | +| 3100201 | Tag running state is abnormal in service. | ## tag.getNfcBTag @@ -187,14 +189,14 @@ Obtains an **NfcBTag** object, which allows access to the tags that use the NFC- **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)**. +| 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** | -| ------------------------------------- | ------------- | +| **Type** | **Description** | +| ------------------------------------- | ------------------ | | [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.| ## tag.getNfcB9+ @@ -207,23 +209,23 @@ Obtains an **NfcBTag** object, which allows access to the tags that use the NFC- **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)**. +| 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** | -| ------------------------------------- | ------------- | +| **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. | +| ID| Error Message | +| -------- | ----------------------------------------- | +| 3100201 | Tag running state is abnormal in service. | ## tag.getNfcFTag @@ -238,14 +240,14 @@ Obtains an **NfcFTag** object, which allows access to the tags that use the NFC- **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)**. +| 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** | -| ------------------------------------- | ------------- | +| **Type** | **Description** | +| ------------------------------------- | ------------------ | | [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.| ## tag.getNfcF9+ @@ -258,23 +260,23 @@ Obtains an **NfcFTag** object, which allows access to the tags that use the NFC- **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)**. +| 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** | -| ------------------------------------- | ------------- | +| **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. | +| ID| Error Message | +| -------- | ----------------------------------------- | +| 3100201 | Tag running state is abnormal in service. | ## tag.getNfcVTag @@ -289,14 +291,14 @@ Obtains an **NfcVTag** object, which allows access to the tags that use the NFC- **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)**. +| 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** | -| ------------------------------------- | ------------- | +| **Type** | **Description** | +| ------------------------------------- | ------------------ | | [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.| ## tag.getNfcV9+ @@ -309,23 +311,23 @@ Obtains an **NfcVTag** object, which allows access to the tags that use the NFC- **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)**. +| 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** | -| ------------------------------------- | ------------- | +| **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. | +| ID| Error Message | +| -------- | ----------------------------------------- | +| 3100201 | Tag running state is abnormal in service. | ## tag.getIsoDep9+ @@ -337,23 +339,23 @@ Obtains an **IsoDepTag** object, which allows access to the tags that use the IS **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)**.| +| 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** | -| ---------------------------------------- | ----------------------------------- | +| **Type** | **Description** | +| ------------------------------------------ | ------------------------------------------------------- | | [IsoDepTag](js-apis-nfctech.md#isodeptag9) | **IsoDepTag** 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. | +| ID| Error Message | +| -------- | ----------------------------------------- | +| 3100201 | Tag running state is abnormal in service. | ## tag.getNdef9+ @@ -365,23 +367,23 @@ Obtains an **NdefTag** object, which allows access to the tags in the NFC Data E **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)**.| +| 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** | -| -------------------------------------- | ------------------------------- | +| **Type** | **Description** | +| -------------------------------------- | --------------------------------------------------- | | [NdefTag](js-apis-nfctech.md#ndeftag9) | **NdefTag** 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. | +| ID| Error Message | +| -------- | ----------------------------------------- | +| 3100201 | Tag running state is abnormal in service. | ## tag.getMifareClassic9+ @@ -393,23 +395,23 @@ Obtains a **MifareClassicTag** object, which allows access to the tags that use **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)**.| +| 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** | -| ---------------------------------------- | ---------------------------------------- | +| **Type** | **Description** | +| --------------------------------------------------------- | ----------------------------------------------------------------------- | | [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | **MifareClassicTag** 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. | +| ID| Error Message | +| -------- | ----------------------------------------- | +| 3100201 | Tag running state is abnormal in service. | ## tag.getMifareUltralight9+ @@ -420,23 +422,23 @@ Obtains a **MifareUltralightTag** object, which allows access to the tags that u **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)**.| +| 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** | -| ---------------------------------------- | ---------------------------------------- | +| **Type** | **Description** | +| -------------------------------------------------------------- | ----------------------------------------------------------------------------- | | [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9) | **MifareUltralightTag** 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. | +| ID| Error Message | +| -------- | ----------------------------------------- | +| 3100201 | Tag running state is abnormal in service. | ## tag.getNdefFormatable9+ @@ -448,17 +450,17 @@ Obtains an **NdefFormatableTag** object, which allows access to the tags that ar **Return value** -| **Type** | **Description** | -| ---------------------------------------- | ---------------------------------------- | +| **Type** | **Description** | +| --------------------------------------------------------- | ------------------------------------------------------------------------- | | [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag) | **NdefFormatableTag** 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. | +| ID| Error Message | +| -------- | ----------------------------------------- | +| 3100201 | Tag running state is abnormal in service. | ## tag.getTagInfo9+ @@ -470,14 +472,14 @@ Obtains **TagInfo** from **Want**, which is initialized by the NFC service and c **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ---------------------------------------- | ---- | --------------------------------- | -| want | [Want](js-apis-app-ability-want.md#Want) | Yes | Data obtained from the parameters of the **onCreate** entry function when an ability is dispatched.| +| Name| Type | Mandatory| Description | +| ------ | ---------------------------------------- | ---- | --------------------------------------------------- | +| want | [Want](js-apis-app-ability-want.md#Want) | Yes | Data obtained from the parameters of the **onCreate** entry function when an ability is dispatched.| **Return value** -| **Type** | **Description** | -| ------------------- | --------------------------- | +| **Type** | **Description** | +| ------------------- | -------------------------------------------- | | [TagInfo](#taginfo) | **TagInfo** object obtained.| @@ -491,14 +493,14 @@ Creates an NDEF record based on the specified URI. **Parameters** -| Name | Type | Mandatory | Description | -| ---- | ------ | ---- | ---------------------- | -| uri | string | Yes | Data to write to the NDEF record.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | --------------------------------- | +| uri | string | Yes | Data to write to the NDEF record.| **Return value** -| **Type** | **Description** | -| -------------------------- | ---------------------------------------- | +| **Type** | **Description** | +| -------------------------- | ------------------------------------------------------------ | | [NdefRecord](#ndefrecord9) | NDEF record created. For details, see *NFCForum-TS-NDEF_1.0*.| **Example** @@ -530,15 +532,15 @@ Creates an NDEF record based on the specified text data and encoding type. **Parameters** -| Name | Type | Mandatory | Description | -| ------ | ------ | ---- | ------------------------ | -| text | string | Yes | Text to write to the NDEF record.| -| locale | string | Yes | Encoding mode of the text. | +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------------------- | +| text | string | Yes | Text to write to the NDEF record.| +| locale | string | Yes | Encoding mode of the text. | **Return value** -| **Type** | **Description** | -| -------------------------- | ---------------------------------------- | +| **Type** | **Description** | +| -------------------------- | ------------------------------------------------------------ | | [NdefRecord](#ndefrecord9) | NDEF record created. For details, see *NFCForum-TS-NDEF_1.0*.| **Example** @@ -572,15 +574,15 @@ Creates an NDEF record based on the specified MIME data and type. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------- | ---- | ---------------------------------------- | -| mimeType | string | Yes | MIME type that complies with RFC rules, for example, **text/plain** or **image/jpeg**.| -| mimeData | number[] | Yes | MIME data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. | +| Name | Type | Mandatory| Description | +| -------- | -------- | ---- | ------------------------------------------------------- | +| mimeType | string | Yes | MIME type that complies with RFC rules, for example, **text/plain** or **image/jpeg**.| +| mimeData | number[] | Yes | MIME data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| **Return value** -| **Type** | **Description** | -| -------------------------- | ---------------------------------------- | +| **Type** | **Description** | +| -------------------------- | ------------------------------------------------------------ | | [NdefRecord](#ndefrecord9) | NDEF record created. For details, see *NFCForum-TS-NDEF_1.0*.| **Example** @@ -612,16 +614,16 @@ Creates an NDEF record based on application-specific data. **Parameters** -| Name | Type | Mandatory | Description | -| ------------ | -------- | ---- | ----------------------------------- | -| domainName | string | Yes | Bundle name of the application or domain name of the organization that releases the applications. | -| type | string | Yes | Type of the application data. | -| externalData | number[] | Yes | Application data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| +| Name | Type | Mandatory| Description | +| ------------ | -------- | ---- | ------------------------------------------------------- | +| domainName | string | Yes | Bundle name of the application or domain name of the organization that releases the applications. | +| type | string | Yes | Type of the application data. | +| externalData | number[] | Yes | Application data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| **Return value** -| **Type** | **Description** | -| -------------------------- | ---------------------------------------- | +| **Type** | **Description** | +| -------------------------- | ------------------------------------------------------------ | | [NdefRecord](#ndefrecord9) | NDEF record created. For details, see *NFCForum-TS-NDEF_1.0*.| **Example** @@ -655,14 +657,14 @@ Converts an NDEF message to bytes. **Parameters** -| Name | Type | Mandatory | Description | -| ----------- | ---------------------------------------- | ---- | ----------- | -| ndefMessage | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | Yes | NDEF message to convert.| +| Name | Type | Mandatory| Description | +| ----------- | ---------------------------------------------- | ---- | ------------------ | +| ndefMessage | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | Yes | NDEF message to convert.| **Return value** -| **Type** | **Description** | -| -------- | ---------------------------------------- | +| **Type**| **Description** | +| -------- | ------------------------------------------------------------------------------------- | | number[] | NDEF message in bytes, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| **Example** @@ -696,14 +698,14 @@ Creates an NDEF message from raw byte data. The data must comply with the NDEF r **Parameters** -| **Name**| **Type** | **Mandatory**| **Description** | -| ------- | -------- | ------ | ---------------------------------------- | -| data | number[] | Yes | Raw byte data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. The data must comply with the NDEF record format.| +| **Name**| **Type**| **Mandatory**| **Description** | +| ---------- | -------- | -------- | ---------------------------------------------------------------------------------- | +| data | number[] | Yes | Raw byte data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. The data must comply with the NDEF record format.| **Return value** -| **Type** | **Description** | -| ---------------------------------------- | ---------------------------------------- | +| **Type** | **Description** | +| ---------------------------------------------- | ------------------------------------------------------------- | | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | NDEF message created. For details, see *NFCForum-TS-NDEF_1.0*.| **Example** @@ -730,14 +732,14 @@ Creates an NDEF message from the NDEF records list. **Parameters** -| **Name** | **Type** | **Mandatory**| **Description** | -| ----------- | ---------------------------------------- | ------ | ---------------------------------------- | -| ndefRecords | [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | Yes | NDEF record list used to create the NDEF message. For details, see *NFCForum-TS-NDEF_1.0*.| +| **Name** | **Type** | **Mandatory**| **Description** | +| ----------- | --------------------------------------------- | -------- | ---------------------------------------------------------------- | +| ndefRecords | [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | Yes | NDEF record list used to create the NDEF message. For details, see *NFCForum-TS-NDEF_1.0*.| **Return value** -| **Type** | **Description** | -| ---------------------------------------- | ---------------------------------------- | +| **Type** | **Description** | +| ---------------------------------------------- | ------------------------------------------------------------- | | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | NDEF message created. For details, see *NFCForum-TS-NDEF_1.0*.| **Example** @@ -765,114 +767,113 @@ Defines the **TagInfo** object, which provides information about the tag technol **Required permissions**: ohos.permission.NFC_TAG -| **Name** | **Type** | **Readable**| **Writable**| **Description** | -| ----------------------------- | ---------------------------------------- | ------ | ------ | ---------------------------------------- | -| uid9+ | number[] | Yes | No | Tag unique identifier (UID), which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. | -| technology9+ | number[] | Yes | No | Supported technologies. Each number is a constant indicating the supported technology. | -| supportedProfiles | number[] | Yes | No | Supported profiles. This parameter is not supported since API version 9. Use [tag.TagInfo#technology](#tagtaginfo) instead.| -| extrasData9+ | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | Yes | No | Extended attribute value of the tag technology.
**System API**: This is a system API. | -| tagRfDiscId9+ | number | Yes | No | ID allocated when the tag is discovered.
**System API**: This is a system API. | -| remoteTagService9+ | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes | No | Remote object of the NFC service process used for interface communication between the client and the service.
**System API**: This is a system API.| +| **Name** | **Type** | **Readable**| **Writable**| **Description** | +| ----------------------------- | ------------------------------------------------------------- | -------- | -------- | -------------------------------------------------------------------------------------------- | +| uid9+ | number[] | Yes | No | Tag unique identifier (UID), which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. | +| technology9+ | number[] | Yes | No | Supported technologies. Each number is a constant indicating the supported technology. | +| supportedProfiles | number[] | Yes | No | Supported profiles. This parameter is not supported since API version 9. Use [tag.TagInfo#technology](#tagtaginfo) instead. | +| extrasData9+ | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | Yes | No | Extended attribute value of the tag technology.
**System API**: This is a system API. | +| tagRfDiscId9+ | number | Yes | No | ID allocated when the tag is discovered.
**System API**: This is a system API. | +| remoteTagService9+ | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes | No | Remote object of the NFC service process used for interface communication between the client and the service.
**System API**: This is a system API.| ## NdefRecord9+ Defines an NDEF record. For details, see *NFCForum-TS-NDEF_1.0*. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name** | **Type** | **Readable**| **Writable**| **Description** | -| ------- | -------- | ------ | ------ | ---------------------------------------- | -| tnf | number | Yes | No | Type name field (TNF) of the NDEF record. | -| rtdType | number[] | Yes | No | Record type definition (RTD) of the NDEF record. It consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| -| id | number[] | Yes | No | NDEF record ID, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| -| payload | number[] | Yes | No | NDEF payload, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| +| **Name**| **Type**| **Readable**| **Writable**| **Description** | +| -------- | -------- | -------- | -------- | ----------------------------------------------------------------------------------------- | +| tnf | number | Yes | No | Type name field (TNF) of the NDEF record. | +| rtdType | number[] | Yes | No | Record type definition (RTD) of the NDEF record. It consists of hexadecimal numbers ranging from **0x00** to **0xFF**.| +| id | number[] | Yes | No | NDEF record ID, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. | +| payload | number[] | Yes | No | NDEF payload, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. | ## Technology Type Definition Enumerates the tag technology types. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name** | **Value**| **Description** | -| ---------------------------- | ----- | ------------------------ | -| NFC_A | 1 | NFC-A (ISO 14443-3A). | +| **Name** | **Value**| **Description** | +| ---------------------------- | ------ | --------------------------- | +| NFC_A | 1 | NFC-A (ISO 14443-3A). | | NFC_B | 2 | NFC-B (ISO 14443-3B).| -| ISO_DEP | 3 | ISO-DEP (ISO 14443-4).| -| NFC_F | 4 | NFC-F (JIS 6319-4). | -| NFC_V | 5 | NFC-V (ISO 15693). | -| NDEF | 6 | NDEF. | -| NDEF_FORMATABLE9+ | 7 | NDEF formattable. | -| MIFARE_CLASSIC | 8 | MIFARE Classic. | -| MIFARE_ULTRALIGHT | 9 | MIFARE Ultralight. | +| ISO_DEP | 3 | ISO-DEP (ISO 14443-4).| +| NFC_F | 4 | NFC-F (JIS 6319-4). | +| NFC_V | 5 | NFC-V (ISO 15693). | +| NDEF | 6 | NDEF. | +| NDEF_FORMATABLE9+ | 7 | NDEF formattable. | +| MIFARE_CLASSIC | 8 | MIFARE Classic. | +| MIFARE_ULTRALIGHT | 9 | MIFARE Ultralight. | ## TnfType9+ Enumerates the TNF types. For details, see *NFCForum-TS-NDEF_1.0*. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name** | **Value**| **Description** | -| ---------------- | ----- | ---------------------------------------- | -| TNF_EMPTY | 0x0 | Empty. | -| TNF_WELL_KNOWN | 0x1 | NFC Forum Well Known Type [NFC RTD]. | -| TNF_MEDIA | 0x2 | Media-type as defined in RFC 2046 [RFC 2046].| -| TNF_ABSOLUTE_URI | 0x3 | Absolute URI as defined in RFC 3986 [RFC 3986].| -| TNF_EXT_APP | 0x4 | NFC Forum external type [NFC RTD]. | -| TNF_UNKNOWN | 0x5 | Unknown. | -| TNF_UNCHANGED | 0x6 | Unchanged (see section 2.3.3 in *NFCForum-TS-NDEF_1.0*). | +| **Name** | **Value**| **Description** | +| ---------------- | ------ | ------------------------------------------------ | +| TNF_EMPTY | 0x0 | Empty. | +| TNF_WELL_KNOWN | 0x1 | NFC Forum Well Known Type [NFC RTD]. | +| TNF_MEDIA | 0x2 | Media-type as defined in RFC 2046 [RFC 2046]. | +| TNF_ABSOLUTE_URI | 0x3 | Absolute URI as defined in RFC 3986 [RFC 3986].| +| TNF_EXT_APP | 0x4 | NFC Forum external type [NFC RTD]. | +| TNF_UNKNOWN | 0x5 | Unknown. | +| TNF_UNCHANGED | 0x6 | Unchanged (see section 2.3.3 in *NFCForum-TS-NDEF_1.0*). | ## NDEF Record RTD Enumerates the NDEF record types. For details about the RTD, see *NFCForum-TS-NDEF_1.0*. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name** | **Value** | **Description** | -| --------------------- | ------ | ------------------ | -| RTD_TEXT9+ | [0x54] | NDEF record of the text type. | -| RTD_URI9+ | [0x55] | NDEF record of the URI type.| +| **Name** | **Value**| **Description** | +| --------------------- | ------ | ----------------------- | +| RTD_TEXT9+ | [0x54] | NDEF record of the text type.| +| RTD_URI9+ | [0x55] | NDEF record of the URI type. | ## NfcForumType9+ Enumerates the NFC Forum tag types. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name** | **Value**| **Description** | -| ---------------- | ----- | ----------------- | -| NFC_FORUM_TYPE_1 | 1 | NFC Forum tag type 1. | -| NFC_FORUM_TYPE_2 | 2 | NFC Forum tag type 2. | -| NFC_FORUM_TYPE_3 | 3 | NFC Forum tag type 3. | -| NFC_FORUM_TYPE_4 | 4 | NFC Forum tag type 4. | -| MIFARE_CLASSIC | 101 | MIFARE Classic.| +| **Name** | **Value**| **Description** | +| ---------------- | ------ | -------------------- | +| NFC_FORUM_TYPE_1 | 1 | NFC Forum tag type 1. | +| NFC_FORUM_TYPE_2 | 2 | NFC Forum tag type 2. | +| NFC_FORUM_TYPE_3 | 3 | NFC Forum tag type 3. | +| NFC_FORUM_TYPE_4 | 4 | NFC Forum tag type 4. | +| MIFARE_CLASSIC | 101 | MIFARE Classic.| ## MifareClassicType9+ Enumerates the MIFARE Classic tag types. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name** | **Value**| **Description** | -| ------------ | ----- | ----------------- | -| TYPE_UNKNOWN | 0 | Unknown type. | -| TYPE_CLASSIC | 1 | MIFARE Classic.| -| TYPE_PLUS | 2 | MIFARE Plus. | -| TYPE_PRO | 3 | MIFARE Pro. | +| **Name** | **Value**| **Description** | +| ------------ | ------ | -------------------- | +| TYPE_UNKNOWN | 0 | Unknown type. | +| TYPE_CLASSIC | 1 | MIFARE Classic.| +| TYPE_PLUS | 2 | MIFARE Plus. | +| TYPE_PRO | 3 | MIFARE Pro. | ## MifareClassicSize9+ Enumerates the sizes of a MIFARE Classic tag. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name** | **Value**| **Description** | -| ------------ | ----- | ------------------ | -| MC_SIZE_MINI | 320 | Each tag has 5 sectors, and each sector has 4 blocks. | -| MC_SIZE_1K | 1024 | Each tag has 16 sectors, and each sector has 4 blocks.| -| MC_SIZE_2K | 2048 | Each tag has 32 sectors, and each sector has 4 blocks.| -| MC_SIZE_4K | 4096 | Each tag has 40 sectors, and each sector has 4 blocks.| +| **Name** | **Value**| **Description** | +| ------------ | ------ | --------------------------------- | +| MC_SIZE_MINI | 320 | Each tag has 5 sectors, and each sector has 4 blocks. | +| MC_SIZE_1K | 1024 | Each tag has 16 sectors, and each sector has 4 blocks.| +| MC_SIZE_2K | 2048 | Each tag has 32 sectors, and each sector has 4 blocks.| +| MC_SIZE_4K | 4096 | Each tag has 40 sectors, and each sector has 4 blocks.| ## MifareUltralightType9+ Enumerates the MIFARE Ultralight tag types. **System capability**: SystemCapability.Communication.NFC.Tag -| **Name** | **Value**| **Description** | -| ----------------- | ----- | ---------------------- | -| TYPE_UNKNOWN | 0 | Unknown type. | -| TYPE_ULTRALIGHT | 1 | MIFARE Ultralight. | -| TYPE_ULTRALIGHT_C | 2 | MIFARE Ultralight C.| - - \ No newline at end of file +| **Name** | **Value**| **Description** | +| ----------------- | ------ | ------------------------- | +| TYPE_UNKNOWN | 0 | Unknown type. | +| TYPE_ULTRALIGHT | 1 | MIFARE Ultralight. | +| TYPE_ULTRALIGHT_C | 2 | MIFARE Ultralight C.| + diff --git a/en/application-dev/reference/apis/js-apis-secureElement.md b/en/application-dev/reference/apis/js-apis-secureElement.md index 429058cec7..4314ea8176 100644 --- a/en/application-dev/reference/apis/js-apis-secureElement.md +++ b/en/application-dev/reference/apis/js-apis-secureElement.md @@ -43,10 +43,10 @@ The returned **SEService** object is available only when **true** is returned by **Parameters** -| **Name**| **Type** | **Description** | -| ---------- | ---------------------------------------------------- | -------------------- | -| type | string | 'serviceState' | -| callback | Callback<[ServiceState](#secureelementservicestate)> | Callback invoked to return the SE service status.| +| **Name**| **Type** | **Mandatory**| **Description** | +| ---------- | ---------------------------------------------------- | ------ | -------------------- | +| type | string | Yes | 'serviceState' | +| callback | Callback<[ServiceState](#secureelementservicestate)> | Yes | Callback invoked to return the SE service status.| **Return value** @@ -59,20 +59,18 @@ The returned **SEService** object is available only when **true** is returned by ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcSEService: secureElement.SEService = null; +let nfcSEService = null; -this.result = "Service state is Unkown"; try { - this.nfcSEService = secureElement.newSEService("serviceState", (state) => { + nfcSEService = secureElement.newSEService("serviceState", (state) => { if (state == secureElement.ServiceState.DISCONNECTED) { - this.result = "Service state is Disconnected"; + console.log("Service state is Disconnected"); } else { - this.result = "Service state is Connected"; + console.log.("Service state is Connected"); } }); } catch (e) { - this.result = "newSEService occurs exception:" + e.message; + console.log("newSEService occurs exception:" + e.message); } ``` @@ -95,35 +93,34 @@ Obtains the available SE readers. The returned array cannot contain duplicate ob ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcSEService: secureElement.SEService = null; -@State nfcServiceState: secureElement.ServiceState = null; -@State nfcOmaReader: secureElement.Reader = null; -@State nfcOmaReaderList: secureElement.Reader[] = null; +let nfcSEService = null; +let nfcServiceState = null; +let nfcOmaReader = null; +let nfcOmaReaderList = null; // get SEService try { - this.nfcSEService = secureElement.newSEService("serviceState", (state) => { + nfcSEService = secureElement.newSEService("serviceState", (state) => { if (state == secureElement.ServiceState.DISCONNECTED) { - this.result = "Service state is Disconnected"; + console.log("Service state is Disconnected"); } else { - this.result = "Service state is Connected"; + console.log("Service state is Connected"); } }); } catch (e) { - this.result = "newSEService excpetion:" + e.message; + console.log("newSEService excpetion:" + e.message); } try { - this.nfcOmaReaderList = this.nfcSEService.getReaders(); - if (this.nfcOmaReaderList != null && this.nfcOmaReaderList.length > 0) { - this.nfcOmaReader = this.nfcOmaReaderList[0]; - this.result = "get reader successfully"; + nfcOmaReaderList = nfcSEService.getReaders(); + if (nfcOmaReaderList != null && nfcOmaReaderList.length > 0) { + nfcOmaReader = this.nfcOmaReaderList[0]; + console.log("get reader successfully"); } else { - this.result = "get reader failed"; + console.log("get reader failed"); } } catch (e) { - this.result = "getReaders exception:" + e.message; + console.log("getReaders exception:" + e.message); } ``` @@ -146,20 +143,19 @@ Checks whether this SE service is connected. ```JS import secureElement from '@ohos.secureElement'; -@State result: string = '' -@State nfcSEService: secureElement.SEService = null; +let nfcSEService = null; try { let ret: boolean; // refer to newSEService for this.nfcSEService - ret = this.nfcSEService.isConnected(); + ret = nfcSEService.isConnected(); if (ret) { - this.result = 'get state: connected'; + console.log("get state: connected"); } else { - this.result = 'get state: not connected'; + console.log("get state: not connected"); } } catch (e) { - this.result = "isConnected exception: " + e.message; + console.log("isConnected exception: " + e.message); } ``` @@ -176,15 +172,15 @@ Releases all SE resources allocated to this service. After that, [isConnected](# ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcSEService: secureElement.SEService = null; + +let nfcSEService = null; try { // refer to newSEService for this.nfcSEService - this.nfcSEService.shutdown(); - this.result = "shutdown successfully"; + nfcSEService.shutdown(); + console.log("shutdown successfully"); } catch (e) { - this.result = "shutdown exception:" + e.message; + console.log("shutdown exception:" + e.message); } ``` @@ -207,15 +203,14 @@ Obtains the version of the Open Mobile API Specification used for the implementa ```JS import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcSEService: secureElement.SEService = null; +let nfcSEService = null; this.result = "version: " try { // refer to newSEService for this.nfcSEService - this.result += this.nfcSEService.getVersion(); + console.log("version: " + nfcSEService.getVersion()); } catch (e) { - this.result = "getVersion exception:" + e.message; + console.log("getVersion exception:" + e.message); } ``` @@ -238,14 +233,13 @@ Obtains the reader name. If the card reader is a SIM reader, its name must be in ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaReader: secureElement.Reader = null; +let nfcOmaReader = null; try { // refer to SEService.getReaders for this.nfcOmaReader - this.result = this.nfcOmaReader.getName(); + console.log(nfcOmaReader.getName()); } catch (e) { - this.result = "getName exception:" + e.message; + console.log("getName exception:" + e.message); } ``` @@ -276,18 +270,17 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaReader: secureElement.Reader = null; +let nfcOmaReader = null; try { // refer to SEService.getReaders for this.nfcOmaReader - if (this.nfcOmaReader.isSecureElementPresent()) { - this.result = "isSecureElementPresent TRUE"; + if (nfcOmaReader.isSecureElementPresent()) { + console.log("isSecureElementPresent TRUE"); } else { - this.result = "isSecureElementPresent FALSE"; + console.log("isSecureElementPresent FALSE"); } } catch (e) { - this.result = "isSecureElementPresent exception:" + e.message; + console.log("isSecureElementPresent exception:" + e.message); } ``` @@ -319,20 +312,19 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaReader: secureElement.Reader = null; -@State nfcOmaSession: secureElement.Session = null; +let nfcOmaReader = null; +let nfcOmaSession = null; try { // refer to SEService.getReaders for this.nfcOmaReader - this.nfcOmaSession = this.nfcOmaReader.openSession(); - if (this.nfcOmaSession) { - this.result = "get session successfully"; + nfcOmaSession = nfcOmaReader.openSession(); + if (nfcOmaSession) { + console.log("get session successfully"); } else { - this.result = "get session failed"; + console.log("get session failed"); } } catch (e) { - this.result = "OpenSession exception: " + e.message; + console.log("OpenSession exception: " + e.message); } ``` @@ -357,15 +349,14 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaReader: secureElement.Reader = null; +nfcOmaReader = null; try { // refer to SEService.getReaders for this.nfcOmaReader - this.nfcOmaReader.closeSessions(); - this.result = "close Sessions successfully"; + nfcOmaReader.closeSessions(); + console.log("close Sessions successfully"); } catch (e) { - this.result = "closeSessions exception:" + e.message; + console.log("closeSessions exception:" + e.message); } ``` @@ -388,20 +379,19 @@ Obtains the reader that provides this session. ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaReader: secureElement.Reader = null; -@State nfcOmaSession: secureElement.Session = null; +let nfcOmaReader = null; +let nfcOmaSession = null; try { - // refer to Reader.openSession for this.nfcOmaSession - this.nfcOmaReader = this.nfcOmaSession.getReader(); - if (this.nfcOmaReader) { - this.result = "get reader successfully"; + // See Reader.openSession for this.nfcOmaSession. + nfcOmaReader = nfcOmaSession.getReader(); + if (nfcOmaReader) { + console.log("get reader successfully"); } else { - this.result = "get reader failed"; + console.log("get reader failed"); } } catch (e) { - this.result = "getReader exception:" + e.message; + console.log("getReader exception:" + e.message); } ``` @@ -432,24 +422,25 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; +let nfcOmaSession = null; +let str = ""; try { - // refer to Reader.openSession for this.nfcOmaSession - let ret = this.nfcOmaSession.getATR(); + // See Reader.openSession for this.nfcOmaSession. + let ret = nfcOmaSession.getATR(); if (ret) { - this.result = "getATR result:["; + str = 'getATR result:['; for (let i = 0; i < ret.length; ++i) { - this.result += ret[i]; - this.result += ' '; + str += ret[i]; + str += ' '; } - this.result += ']'; + str += ']'; + console.log(str); } else { - this.result = "getATR result is null"; + console.log("getATR result is null"); } } catch (e) { - this.result = "getATR exception:" + e.message; + console.log("getATR exception:" + e.message); } ``` @@ -474,15 +465,14 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; +let nfcOmaSession = null; try { - // refer to Reader.openSession for this.nfcOmaSession - this.nfcOmaSession.close(); - this.result = "session close successfully"; + // See Reader.openSession for this.nfcOmaSession. + nfcOmaSession.close(); + console.log("session close successfully"); } catch (e) { - this.result = "session close exception:" + e.message; + console.log("session close exception:" + e.message); } ``` @@ -509,19 +499,18 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```Js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; +let nfcOmaSession = null; try { - // refer to Reader.openSession for this.nfcOmaSession - let ret = this.nfcOmaSession.isClosed(); + // See Reader.openSession for this.nfcOmaSession. + let ret = nfcOmaSession.isClosed(); if (ret) { - this.result = "session state is closed"; + console.log("session state is closed"); } else { - this.result = "session state is not closed"; + console.log("session state is not closed"); } } catch (e) { - this.result = "isClosed exception:" + e.message; + console.log("isClosed exception:" + e.message); } ``` @@ -546,21 +535,20 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; +let nfcOmaSession = null; try { - // refer to Reader.openSession for this.nfcOmaSession - this.nfcOmaSession.closeChannels(); - this.result = "close Channels successfully"; + // See Reader.openSession for this.nfcOmaSession. + nfcOmaSession.closeChannels(); + console.log("close Channels successfully"); } catch (e) { - this.result = "closeChannels exception:" + e.message; + console.log("closeChannels exception:" + e.message); } ``` ## Session.openBasicChannel -openBasicChannel(aid: number[]): Promise +openBasicChannel(aid: number[]): Promise\ Opens a basic channel. This API uses a promise to return the result. @@ -568,15 +556,15 @@ Opens a basic channel. This API uses a promise to return the result. **Parameters** -| **Name**| **Type**| **Description** | -| ---------- | -------- | ------------------------------------------------------------ | -| aid | number[] | AIDs of the applets selected on this channel or null if no applet is selected. | +| **Name**| **Type**| **Mandatory**| **Description** | +| ---------- | -------- | ------ | ------------------------------------------------------------ | +| aid | number[] | Yes |AIDs of the applets selected on this channel or null if no applet is selected.| **Return value** | **Type**| **Description** | | -------- | --------------------- | -| Channel | Returns the **Channel** instance opened. If the SE cannot provide a new basic channel or cannot obtain the access control rule due to lack of available basic channels, null will be returned. | +| Channel | Returns the **Channel** instance opened. If the SE cannot provide a new basic channel or cannot obtain the access control rule due to lack of available basic channels, null will be returned.| **Error codes** @@ -594,27 +582,26 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; -@State nfcOmaChannel: secureElement.Channel = null; +let nfcOmaSession = null; +let nfcOmaChannel = null; try { // See Reader.openSession for this.nfcOmaSession. - let getPromise = this.nfcOmaSession.openBasicChannel(this.aidArray); + let getPromise = nfcOmaSession.openBasicChannel(this.aidArray); getPromise.then((channel) => { - this.nfcOmaChannel = channel; - this.result = "openBasicChannel1 get channel successfully"; + nfcOmaChannel = channel; + console.log("openBasicChannel1 get channel successfully"); }).catch ((err) => { - this.result = "openBasicChannel1 exception:" + err.message; + console.log("openBasicChannel1 exception:" + err.message); }); } catch (e) { - this.result = "OpenBasicChannel1 exception:" + e.message; + console.log("OpenBasicChannel1 exception:" + e.message); } ``` ## Session.openBasicChannel - openBasicChannel(aid: number[], callback: AsyncCallback): void + openBasicChannel(aid: number[], callback: AsyncCallback\): void Opens a basic channel. This API uses an asynchronous callback to return the result. @@ -622,10 +609,10 @@ Opens a basic channel. This API uses an asynchronous callback to return the resu **Parameters** -| **Name**| **Type** | **Description** | -| ---------- | ---------------------- | ------------------------------------------------------------ | -| aid | number[] | AIDs of the applets selected on this channel or null if no applet is selected. | -| callback | AsyncCallback | Callback invoked to return the **Channel** instance opened. If the SE cannot provide a new basic channel or cannot obtain the access control rule due to lack of available basic channels, null will be returned. | +| **Name**| **Type** | **Mandatory**| **Description** | +| ---------- | ---------------------- | ------ | ------------------------------------------------------------ | +| aid | number[] | Yes | AIDs of the applets selected on this channel or null if no applet is selected.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the **Channel** instance opened. If the SE cannot provide a new basic channel or cannot obtain the access control rule due to lack of available basic channels, null will be returned. | **Error codes** @@ -643,29 +630,28 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; -@State nfcOmaChannel: secureElement.Channel = null; -aidArray: number[] = [720, 1080]; +let nfcOmaSession = null; +let nfcOmaChannel = null; +let aidArray = [720, 1080]; try { // See Reader.openSession for this.nfcOmaSession. - this.nfcOmaSession.openBasicChannel(this.aidArray, (error, data) => { + nfcOmaSession.openBasicChannel(aidArray, (error, data) => { if (error) { - this.result = "openBasicChannel2 failed:" + JSON.stringify(error); + console.log("openBasicChannel2 failed:" + JSON.stringify(error)); return; } - this.nfcOmaChannel = data; - this.result = "openBasicChannel2 get channel successfully"; + nfcOmaChannel = data; + console.log("openBasicChannel2 get channel successfully"); }); } catch (e) { - this.result = "openBasicChannel2 exception:" + e.message; + console.log("openBasicChannel2 exception:" + e.message); } ``` ## Session.openBasicChannel -openBasicChannel(aid: number[], p2: number): Promise +openBasicChannel(aid: number[], p2: number): Promise\ Opens a basic channel. This API uses a promise to return the result. @@ -673,16 +659,16 @@ Opens a basic channel. This API uses a promise to return the result. **Parameters** -| **Name**| **Type**| **Description** | -| ---------- | -------- | ------------------------------------------------------------ | -| aid | number[] | AIDs of the applets selected on this channel or null if no applet is selected. | -| p2 | number | P2 parameter of the **SELECT APDU** command executed on the channel. | +| **Name**| **Type**| **Mandatory**| **Description** | +| ---------- | -------- | ------ | ------------------------------------------------------------ | +| aid | number[] | Yes | AIDs of the applets selected on this channel or null if no applet is selected.| +| p2 | number | Yes |P2 parameter of the **SELECT APDU** command executed on the channel. | **Return value** | **Type**| **Description** | | -------- | --------------------- | -| Channel | Returns the **Channel** instance opened. If the SE cannot provide a new basic channel or cannot obtain the access control rule due to lack of available basic channels, null will be returned. | +| Channel | Returns the **Channel** instance opened. If the SE cannot provide a new basic channel or cannot obtain the access control rule due to lack of available basic channels, null will be returned.| **Error codes** @@ -700,29 +686,28 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; -@State nfcOmaChannel: secureElement.Channel = null; -aidArray: number[] = [720, 1080]; -p2: number = 0x00; +let nfcOmaSession = null; +let nfcOmaChannel = null; +let aidArray = [720, 1080]; +let p2 = 0x00; try { // See Reader.openSession for this.nfcOmaSession. - let getPromise = this.nfcOmaSession.openBasicChannel(this.aidArray, this.p2); + let getPromise = nfcOmaSession.openBasicChannel(aidArray, p2); getPromise.then((channel) => { - this.nfcOmaChannel = channel; - this.result = "openBasicChannel3 get channel successfully"; + nfcOmaChannel = channel; + console.log("openBasicChannel3 get channel successfully"); }).catch ((err) => { - this.result = "openBasicChannel3 exception"; + console.log("openBasicChannel3 exception"); }); } catch (e) { - this.result = "openBasicChannel3 exception:" + e.message; + console.log("openBasicChannel3 exception:" + e.message); } ``` ## Session.openBasicChannel -openBasicChannel(aid: number[], p2:number, callback: AsyncCallback): void +openBasicChannel(aid: number[], p2:number, callback: AsyncCallback\): void Opens a basic channel. This API uses an asynchronous callback to return the result. @@ -730,11 +715,11 @@ Opens a basic channel. This API uses an asynchronous callback to return the resu **Parameters** -| **Name**| **Type** | **Description** | -| ---------- | ---------------------- | ------------------------------------------------------------ | -| aid | number[] | AIDs of the applets selected on this channel or null if no applet is selected. | -| p2 | number | P2 parameter of the **SELECT APDU** command executed on the channel. | -| callback | AsyncCallback | Callback invoked to return the **Channel** instance opened. If the SE cannot provide a new basic channel or cannot obtain the access control rule due to lack of available basic channels, null will be returned. | +| **Name**| **Type** | **Mandatory**| **Description** | +| ---------- | ---------------------- | ------ | ------------------------------------------------------------ | +| aid | number[] | Yes | AIDs of the applets selected on this channel or null if no applet is selected.| +| p2 | number | Yes | P2 parameter of the **SELECT APDU** command executed on the channel. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the **Channel** instance opened. If the SE cannot provide a new basic channel or cannot obtain the access control rule due to lack of available basic channels, null will be returned. | **Error codes** @@ -752,30 +737,30 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; -@State nfcOmaChannel: secureElement.Channel = null; -aidArray: number[] = [720, 1080]; -p2: number = 0x00; + +let nfcOmaSession = null; +let nfcOmaChannel = null; +let aidArray = [720, 1080]; +let p2 = 0x00; try { // See Reader.openSession for this.nfcOmaSession. - this.nfcOmaSession.openBasicChannel(this.aidArray, this.p2, (error, data) => { + nfcOmaSession.openBasicChannel(aidArray, p2, (error, data) => { if (error) { - this.result = "openBasicChannel4 failed:" + JSON.stringify(error); + console.log("openBasicChannel4 failed:" + JSON.stringify(error)); return; } - this.nfcOmaChannel = data; - this.result = "openBasicChannel4 get channel successfully"; + nfcOmaChannel = data; + console.log("openBasicChannel4 get channel successfully"); }); } catch (e) { - this.result = "openBasicChannel4 exception:" + e.message; + console.log("openBasicChannel4 exception:" + e.message); } ``` ## Session.openLogicalChannel -openLogicalChannel(aid: number[]): Promise +openLogicalChannel(aid: number[]): Promise\ Opens a logical channel. This API uses a promise to return the result. @@ -783,9 +768,9 @@ Opens a logical channel. This API uses a promise to return the result. **Parameters** -| **Name**| **Type**| **Description** | -| ---------- | -------- | --------------------------------------- | -| aid | number[] | AIDs of the applets selected on the **Channel** instance. | +| **Name**| **Type**| **Mandatory**| **Description** | +| ---------- | -------- | ------ | --------------------------------------- | +| aid | number[] | Yes | AIDs of the applets selected on the **Channel** instance.| **Return value** @@ -809,28 +794,27 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; -@State nfcOmaChannel: secureElement.Channel = null; -aidArray: number[] = [720, 1080]; +let nfcOmaSession = null; +let nfcOmaChannel = null; +let aidArray = [720, 1080]; try { // See Reader.openSession for this.nfcOmaSession. - let getPromise = this.nfcOmaSession.openLogicalChannel(this.aidArray) + let getPromise = nfcOmaSession.openLogicalChannel(aidArray) getPromise.then((channel) => { - this.nfcOmaChannel = channel; - this.result = "openLogicChannel1 get channel successfully"; + nfcOmaChannel = channel; + console.log("openLogicChannel1 get channel successfully"); }).catch ((err) => { - this.result = "openLogicChannel1 exception:" + err.message; + console.log("openLogicChannel1 exception:" + err.message); }); } catch (e) { - this.result = "openLogicChannel1 exception:" + e.message; + console.log("openLogicChannel1 exception:" + e.message); } ``` ## Session.openLogicalChannel - openLogicalChannel(aid:number[], callback: AsyncCallback): void + openLogicalChannel(aid:number[], callback: AsyncCallback\): void Opens a logical channel. This API uses an asynchronous callback to return the result. @@ -838,10 +822,10 @@ Opens a logical channel. This API uses an asynchronous callback to return the re **Parameters** -| **Name**| **Type** | **Description** | -| ---------- | ---------------------- | ------------------------------------------------------------ | -| aid | number[] | AIDs of the applets selected on the **Channel** instance. | -| callback | AsyncCallback | Callback invoked to return the **Channel** instance opened. If the SE cannot provide a new **Channel** instance or cannot obtain access control rules due to lack of available logical **Channel** instances, null will be returned.| +| **Name**| **Type** | **Mandatory**| **Description** | +| ---------- | ---------------------- | ------ | ------------------------------------------------------------ | +| aid | number[] | Yes | AIDs of the applets selected on the **Channel** instance. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the **Channel** instance opened. If the SE cannot provide a new **Channel** instance or cannot obtain access control rules due to lack of available logical **Channel** instances, null will be returned.| **Error codes** @@ -859,29 +843,28 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; -@State nfcOmaChannel: secureElement.Channel = null; -aidArray: number[] = [720, 1080]; +let nfcOmaSession = null; +let nfcOmaChannel = null; +let aidArray = [720, 1080]; try { // See Reader.openSession for this.nfcOmaSession. - this.nfcOmaSession.openLogicalChannel(this.aidArray, (error, data) => { + nfcOmaSession.openLogicalChannel(aidArray, (error, data) => { if (error) { - this.result = "openLogicChannel2 failed:" + JSON.stringify(error); + console.log("openLogicChannel2 failed:" + JSON.stringify(error)); return; } - this.nfcOmaChannel = data; - this.result = "openLogicChannel2 get channel successfully"; + nfcOmaChannel = data; + console.log("openLogicChannel2 get channel successfully"); }); } catch (e) { - this.result = "openLogicChannel2 exception:" + e.message; + console.log("openLogicChannel2 exception:" + e.message); } ``` ## Session.openLogicalChannel -openLogicalChannel(aid: number[], p2: number): Promise +openLogicalChannel(aid: number[], p2: number): Promise\ Opens a logical channel with the applet represented by the given AID (the AID is not null and the length is not 0). @@ -895,10 +878,10 @@ If the AID is null, this API sends the **MANAGE CHANNEL Open** only. In this cas **Parameters** -| **Name**| **Type**| **Description** | -| ---------- | -------- | ----------------------------------------- | -| aid | number[] | AIDs of the applets selected on the **Channel** instance. | -| p2 | number | P2 parameter of the **SELECT APDU** command executed on the channel. | +| **Name**| **Type**| **Mandatory**| **Description** | +| ---------- | -------- | ------ | ----------------------------------------- | +| aid | number[] | Yes | AIDs of the applets selected on the **Channel** instance.| +| p2 | number | Yes | P2 parameter of the **SELECT APDU** command executed on the channel. | **Error codes** @@ -916,30 +899,30 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; -@State nfcOmaChannel: secureElement.Channel = null; -aidArray: number[] = [720, 1080]; -p2: number = 0x00; -if (this.nfcOmaSession) { +let nfcOmaSession = null; +let nfcOmaChannel = null; +let aidArray = [720, 1080]; +let p2 = 0x00; + +if (nfcOmaSession) { try { // See Reader.openSession for this.nfcOmaSession. - let getPromise = this.nfcOmaSession.openLogicalChannel(this.aidArray, this.p2); + let getPromise = nfcOmaSession.openLogicalChannel(aidArray, p2); getPromise.then((channel) => { - this.nfcOmaChannel = channel; - this.result = "openLogicChannel3 get channel successfully"; + nfcOmaChannel = channel; + console.log("openLogicChannel3 get channel successfully"); }).catch ((err) => { - this.result = "openLogicChannel3 exception"; + console.log("openLogicChannel3 exception"); }) } catch (e) { - this.result = "openLogicChannel3 exception:" + e.message; + console.log("openLogicChannel3 exception:" + e.message); } ``` ## Session.openLogicalChannel -openLogicalChannel(aid: number[], p2: number, callback: AsyncCallback):void +openLogicalChannel(aid: number[], p2: number, callback: AsyncCallback\):void Opens a logical channel with the applet represented by the given AID (the AID is not null and the length is not 0). @@ -953,11 +936,11 @@ If the AID is null, this API sends the **MANAGE CHANNEL Open** only. In this cas **Parameters** -| **Name**| **Type** | **Description** | -| ---------- | ---------------------- | ------------------------------------------------------------ | -| aid | number[] | AIDs of the applets selected on the **Channel** instance. | -| p2 | number | P2 parameter of the **SELECT APDU** command executed on the channel. | -| callback | AsyncCallback | Callback invoked to return the **Channel** instance opened. If the SE cannot provide a new **Channel** instance or cannot obtain access control rules due to lack of available logical **Channel** instances, null will be returned.| +| **Name**| **Type** | **Mandatory**| **Description** | +| ---------- | ---------------------- | ------ | ------------------------------------------------------------ | +| aid | number[] | Yes | AIDs of the applets selected on the **Channel** instance. | +| p2 | number | Yes | P2 parameter of the **SELECT APDU** command executed on the channel. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the **Channel** instance opened. If the SE cannot provide a new **Channel** instance or cannot obtain access control rules due to lack of available logical **Channel** instances, null will be returned.| **Error codes** @@ -975,24 +958,23 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; -@State nfcOmaChannel: secureElement.Channel = null; -aidArray: number[] = [720, 1080]; -p2: number = 0x00; +let nfcOmaSession = null; +let nfcOmaChannel = null; +let aidArray = [720, 1080]; +let p2 = 0x00; try { // See Reader.openSession for this.nfcOmaSession. - this.nfcOmaSession.openLogicalChannel(this.aidArray, this.p2, (error, data) => { + nfcOmaSession.openLogicalChannel(aidArray, p2, (error, data) => { if (error) { - this.result = "openLogicChannel4 failed:" + JSON.stringify(error); + console.log("openLogicChannel4 failed:" + JSON.stringify(error)); return; } - this.nfcOmaChannel = data; - this.result = "openLogicChannel4 get channel successfully"; + nfcOmaChannel = data; + console.log("openLogicChannel4 get channel successfully"); }) } catch (e) { - this.result = "openLogicChannel4 exception:" + e.message; + console.log("openLogicChannel4 exception:" + e.message); } ``` @@ -1015,20 +997,19 @@ Obtains the session that opens this channel. ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; -@State nfcOmaChannel: secureElement.Channel = null; +let nfcOmaSession = null; +let nfcOmaChannel = null; try { // See Session.openBasicChannel for this.nfcOmaChannel. - let ret = this.nfcOmaChannel.getSession(); + let ret = nfcOmaChannel.getSession(); if (ret) { - this.result = "get session successfully"; + console.log("get session successfully"); } else { - this.result = "get session failed"; + console.log("get session failed"); } } catch (e) { - this.result = "getSession exception:" + e.message; + console.log("getSession exception:" + e.message); } ``` @@ -1045,16 +1026,15 @@ Closes the channel of the SE. ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaSession: secureElement.Session = null; -@State nfcOmaChannel: secureElement.Channel = null; +let nfcOmaSession = null; +let nfcOmaChannel = null; try { // See Session.openBasicChannel for this.nfcOmaChannel. - this.nfcOmaChannel.close(); - this.result = "channel close successfully"; + nfcOmaChannel.close(); + console.log("channel close successfully"); } catch (e) { - this.result = "channel close exception:" + e.message; + console.log("channel close exception:" + e.message); } ``` @@ -1077,19 +1057,18 @@ Checks whether this channel is a basic channel. ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaChannel: secureElement.Channel = null; +let nfcOmaChannel = null; try { // See Session.openBasicChannel for this.nfcOmaChannel. - let ret = this.nfcOmaChannel.isBasicChannel(); + let ret = nfcOmaChannel.isBasicChannel(); if (ret) { - this.result = "isBasicChannel TRUE"; + console.log("isBasicChannel TRUE"); } else { - this.result = "isBasicChannel FALSE"; + console.log("isBasicChannel FALSE"); } } catch (e) { - this.result = "isBasicChannel Exception: "+ e.message; + console.log ("isBasicChannelException: "+ e.message); } ``` @@ -1112,19 +1091,18 @@ Checks whether this channel is closed. ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaChannel: secureElement.Channel = null; +let nfcOmaChannel = null; try { // See Session.openBasicChannel for this.nfcOmaChannel. - let ret = this.nfcOmaChannel.isClosed(); + let ret = nfcOmaChannel.isClosed(); if (ret) { - this.result = "channel isClosed TRUE"; + console.log("channel isClosed TRUE"); } else { - this.result = "channel isClosed False"; + console.log("channel isClosed False"); } } catch (e) { - this.result = "Channel isClosed exception:" + e.message; + console.log("Channel isClosed exception:" + e.message); } ``` @@ -1151,24 +1129,25 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaChannel: secureElement.Channel = null; +let str = ''; +let nfcOmaChannel = null; try { // See Session.openBasicChannel for this.nfcOmaChannel. - let ret = this.nfcOmaChannel.getSelectResponse(); + let ret = nfcOmaChannel.getSelectResponse(); if (ret) { - this.result = "getSelectResponse result:["; + str = "getSelectResponse result:["; for (let i = 0; i < ret.length; ++i) { - this.result += ret[i]; - this.result += ' '; + str += ret[i]; + str += ' '; } - this.result += ']'; + str += ']'; + console.log(str); } else { - this.result = "getSelectResponse result is null"; + console.log("getSelectResponse result is null"); } } catch (e) { - this.result = "getSelectResponse exception:" + e.message; + console.log("getSelectResponse exception:" + e.message); } ``` @@ -1182,9 +1161,9 @@ Transmits the **APDU** command to the SE (according to ISO/IEC 7816). This API u **Parameters** -| **Name**| **Type**| **Description** | -| ---------- | -------- | ------------------------------------- | -| command | number[] | AIDs of the applets selected on the channel. | +| **Name**| **Type**| **Mandatory**| **Description** | +| ---------- | -------- | ------ | ------------------------------------- | +| command | number[] | Yes | AIDs of the applets selected on the channel.| **Return value** @@ -1207,25 +1186,25 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaChannel: secureElement.Channel = null; - +let nfcOmaChannel = null; +let str = ""; try { let command: number[] = [100, 200]; // See Session.openBasicChannel for this.nfcOmaChannel. - let getPromise = this.nfcOmaChannel.transmit(command); + let getPromise = nfcOmaChannel.transmit(command); getPromise.then((data) => { - this.result = "transmit1 result:["; + str = "transmit1 result:["; for (let i = 0; i < data.length; ++i) { - this.result += data[i]; - this.result += " "; + str += data[i]; + str += " "; } - this.result += "]"; + str += "]"; + console.log(str); }).catch ((err) => { - this.result = "transmit1 exception:" + err.code; + console.log("transmit1 exception:" + err.code); }) } catch (e) { - this.result = "transit1 exception:" + e.message; + console.log("transit1 exception:" + e.message); } ``` @@ -1239,10 +1218,10 @@ Transmits the **APDU** command to the SE (according to ISO/IEC 7816). This API u **Parameters** -| **Name**| **Type** | **Description** | -| ---------- | ----------------------- | ------------------------------------- | -| command | number[] | AIDs of the applets selected on the channel. | -| callback | AsyncCallback | Callback invoked to return the result. | +| **Name**| **Type** | **Mandatory**| **Description** | +| ---------- | ----------------------- | ------ | ------------------------------------- | +| command | number[] | Yes | AIDs of the applets selected on the channel.| +| callback | AsyncCallback | Yes | Callback invoked to return the result. | **Error codes** @@ -1259,25 +1238,26 @@ For details about error codes, see [SE Error Codes](../errorcodes/errorcode-se.m ```js import secureElement from '@ohos.secureElement'; -@State result: string = ''; -@State nfcOmaChannel: secureElement.Channel = null; +let str = ""; +let nfcOmaChannel = null; try { let command: number[] = [100, 200]; // See Session.openBasicChannel for this.nfcOmaChannel. - this.nfcOmaChannel.transmit(command, (error, data) => { + nfcOmaChannel.transmit(command, (error, data) => { if (error) { - this.result = "transmit2 exception:" + JSON.stringify(error); + console.log("transmit2 exception:" + JSON.stringify(error)); return; } - this.result = "transmit2 result:["; + str = "transmit2 result:["; for (let i = 0; i < data.length; ++i) { - this.result += data[i]; - this.result += " "; + str += data[i]; + str += " "; } - this.result += "]"; + str += "]"; + console.log(str) }); } catch (e) { - this.result = "transit2 exception:" + e.message; + console.log("transit2 exception:" + e.message); } ``` diff --git a/en/application-dev/reference/apis/js-apis-system-storage.md b/en/application-dev/reference/apis/js-apis-system-storage.md index a4a3bb6b5d..d76f92a608 100644 --- a/en/application-dev/reference/apis/js-apis-system-storage.md +++ b/en/application-dev/reference/apis/js-apis-system-storage.md @@ -20,7 +20,7 @@ get(options: GetStorageOptions): void Reads the value stored in the cache based on the specified key. -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core +**System capability**: SystemCapability.DistributedDataManager.Preferences.Core.Lite **Parameters** @@ -55,7 +55,7 @@ set(options: SetStorageOptions): void Sets the value in the cache based on the specified key. -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core +**System capability**: SystemCapability.DistributedDataManager.Preferences.Core.Lite **Parameters** @@ -88,7 +88,7 @@ clear(options?: ClearStorageOptions): void Clears the key-value pairs from the cache. -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core +**System capability**: SystemCapability.DistributedDataManager.Preferences.Core.Lite **Parameters** @@ -119,7 +119,7 @@ delete(options: DeleteStorageOptions): void Deletes the key-value pair based on the specified key. -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core +**System capability**: SystemCapability.DistributedDataManager.Preferences.Core.Lite **Parameters** @@ -147,20 +147,20 @@ export default { ## GetStorageOptions -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core +**System capability**: SystemCapability.DistributedDataManager.Preferences.Core.Lite | Name | Type | Mandatory| Description | | -------- | ---------------- | ---- | ------------------- | | key | string | Yes | Key of the target data. | -| default | string | No | Default value returned when the specified key does not exist. | +| default | string | No | Default value returned when the specified key does not exist. | | success | (data: any) => void | No | Called to return the result when **storage.get()** is called successfully. **data** is the value indexed by the specified key. | | fail | (data: string, code: number) => void | No | Called to return the result when **storage.get()** fails to be called. **data** is the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when **storage.get()** is complete. | +| complete | () => void | No | Called when **storage.get()** is complete. | ## SetStorageOptions -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core +**System capability**: SystemCapability.DistributedDataManager.Preferences.Core.Lite | Name | Type | Mandatory| Description | | -------- | ------------------- | ---- | -------------------- | @@ -173,23 +173,22 @@ export default { ## ClearStorageOptions -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core +**System capability**: SystemCapability.DistributedDataManager.Preferences.Core.Lite | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------- | | success | () => void | No | Called when **storage.clear()** is called successfully. | | fail | (data: string, code: number) => void | No | Called to return the result when **storage.clear()** fails to be called. **data** is the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when **storage.clear()** is complete. | +| complete | () => void | No | Called when **storage.clear()** is complete. | ## DeleteStorageOptions -**System capability**: SystemCapability.DistributedDataManager.Preferences.Core +**System capability**: SystemCapability.DistributedDataManager.Preferences.Core.Lite | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------ | | key | string | Yes | Key of the data to delete. | | success | () => void | No | Called when **storage.delete()** is called successfully. | | fail | (data: string, code: number) => void | No | Called to return the result when **storage.delete()** fails to be called. **data** is the error information, and **code** indicates the error code. | -| complete | () => void | No | Called when **storage.delete()** is complete. | - +| complete | () => void | No | Called when **storage.delete()** is complete. | -- GitLab