@@ -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,8 +67,10 @@ 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
importtagfrom'@ohos.nfc.tag';
importUIAbilityfrom'@ohos.app.ability.UIAbility';
onCreate(want,launchParam){
exportdefaultclassEntryAbilityextendsUIAbility{
onCreate(want,launchParam){
// Add other code here.
// want is initialized by the NFC service and contains tagInfo.
...
...
@@ -118,8 +120,8 @@ onCreate(want, launchParam) {
}
// Other code to read or write this tag.
}
// 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-
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
| 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.|
| 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.|
| 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*.|
| uid<sup>9+</sup> | number[] | Yes | No | Tag unique identifier (UID), which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. |
| technology<sup>9+</sup> | 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.|
| supportedProfiles | number[] | Yes | No | Supported profiles. This parameter is not supported since API version 9. Use [tag.TagInfo#technology](#tagtaginfo) instead. |
| extrasData<sup>9+</sup> | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | Yes | No | Extended attribute value of the tag technology.<br>**System API**: This is a system API. |
| tagRfDiscId<sup>9+</sup> | number | Yes | No | ID allocated when the tag is discovered.<br>**System API**: This is a system API. |
| remoteTagService<sup>9+</sup> | [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.<br>**System API**: This is a system API.|
...
...
@@ -778,12 +780,12 @@ Defines an NDEF record. For details, see *NFCForum-TS-NDEF_1.0*.
| 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**.|
| 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.
...
...
@@ -791,7 +793,7 @@ Enumerates the tag technology types.
| 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
| aid | number[] | AIDs of the applets selected on this channel or null if no applet is selected. |
| callback | AsyncCallback<Channel> | 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. |
| aid | number[] | Yes | AIDs of the applets selected on this channel or null if no applet is selected.|
| callback | AsyncCallback\<Channel> | 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
| 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
| 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<Channel> | 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. |
| 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\<Channel> | 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
| aid | number[] | AIDs of the applets selected on the **Channel** instance. |
| callback | AsyncCallback<Channel> | 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.|
| aid | number[] | Yes | AIDs of the applets selected on the **Channel** instance. |
| callback | AsyncCallback\<Channel> | 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
| 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<Channel> | 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.|
| 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\<Channel> | 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
| 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. |