未验证 提交 b19a9c26 编写于 作者: O openharmony_ci 提交者: Gitee

!22081 bug:NFC docs 文档bug修复,nfctag技术通过uri声明

Merge pull request !22081 from wujie/master
...@@ -23,20 +23,18 @@ ...@@ -23,20 +23,18 @@
// add the nfc tag action // add the nfc tag action
"ohos.nfc.tag.action.TAG_FOUND" "ohos.nfc.tag.action.TAG_FOUND"
],
"uris": [
{
"type":"tag-tech/NfcA"
},
{
"type":"tag-tech/IsoDep"
}
// Add other technology if neccessary,
// such as: NfcB/NfcF/NfcV/Ndef/MifareClassic/MifareUL/NdefFormatable
] ]
} }
],
"metadata": [
{
"name": "tag-tech",
"value": "NfcA"
},
{
"name": "tag-tech",
"value": "IsoDep"
}
// add other technology if neccessary,
// such as: NfcB/NfcF/NfcV/Ndef/MifareClassic/MifareUL/NdefFormatable
] ]
} }
], ],
...@@ -51,9 +49,8 @@ ...@@ -51,9 +49,8 @@
``` ```
> **注意:** > **注意:**
1. 声明"actions"字段的内容填写,必须是"ohos.nfc.tag.action.TAG_FOUND",不能更改。 1. 声明"actions"字段的内容填写,必须是"ohos.nfc.tag.action.TAG_FOUND",不能更改。
2. 声明技术时"metadata"中的"name"字段的内容填写,必须是"tag-tech",不能更改。 2. 声明技术时"uris"中"type"字段的内容填写,前缀必须是"tag-tech/",后面接着NfcA/NfcB/NfcF/NfcV/IsoDep/Ndef/MifareClassic/MifareUL/NdefFormatable"中的一个。如果存在多个"type"时,需要分行填写。填写错误会造成解析失败。
3. 声明技术时"metadata"中的"value"字段的内容填写,必须是"NfcA/NfcB/NfcF/NfcV/IsoDep/Ndef/MifareClassic/MifareUL/NdefFormatable"中的一个或多个。填写错误会造成解析失败。 3. 声明权限时"requestPermissions"中的"name"字段的内容填写,必须是"ohos.permission.NFC_TAG",不能更改。
4. 声明权限时"requestPermissions"中的"name"字段的内容填写,必须是"ohos.permission.NFC_TAG",不能更改。
## **导入模块** ## **导入模块**
...@@ -527,8 +524,16 @@ import tag from '@ohos.nfc.tag'; ...@@ -527,8 +524,16 @@ import tag from '@ohos.nfc.tag';
let elementName = null; let elementName = null;
let discTech = [tag.NFC_A, tag.NFC_B]; // replace with the tech(s) that is needed by foreground ability let discTech = [tag.NFC_A, tag.NFC_B]; // replace with the tech(s) that is needed by foreground ability
function foregroundCb(tagInfo: any) {
console.log("foreground callback: tag found tagInfo = ", JSON.stringify(tagInfo)); function foregroundCb(err, taginfo) {
if (!err) {
console.log("foreground callback: tag found tagInfo = ", JSON.stringify(tagInfo));
} else {
console.log("foreground callback err: " + err.message);
return;
}
// other Operations of taginfo
} }
export default class MainAbility extends UIAbility { export default class MainAbility extends UIAbility {
...@@ -884,7 +889,7 @@ NFC Tag有多种不同的技术类型,定义常量描述不同的技术类型 ...@@ -884,7 +889,7 @@ NFC Tag有多种不同的技术类型,定义常量描述不同的技术类型
| **名称** | **值** | **说明** | | **名称** | **值** | **说明** |
| ---------------------------- | ------ | --------------------------- | | ---------------------------- | ------ | --------------------------- |
| NFC_A | 1 | NFC-A (ISO 14443-3A)技术。 | | NFC_A | 1 | NFC-A (ISO 14443-3A)技术。 |
| NFC_B | 2 | NFC-A (ISO 14443-3B)技术。 | | NFC_B | 2 | NFC-B (ISO 14443-3B)技术。 |
| ISO_DEP | 3 | ISO-DEP (ISO 14443-4)技术。 | | ISO_DEP | 3 | ISO-DEP (ISO 14443-4)技术。 |
| NFC_F | 4 | NFC-F (JIS 6319-4)技术。 | | NFC_F | 4 | NFC-F (JIS 6319-4)技术。 |
| NFC_V | 5 | NFC-V (ISO 15693)技术。 | | NFC_V | 5 | NFC-V (ISO 15693)技术。 |
......
...@@ -66,7 +66,7 @@ try { ...@@ -66,7 +66,7 @@ try {
if (state == secureElement.ServiceState.DISCONNECTED) { if (state == secureElement.ServiceState.DISCONNECTED) {
console.log("Service state is Disconnected"); console.log("Service state is Disconnected");
} else { } else {
console.log.("Service state is Connected"); console.log("Service state is Connected");
} }
}); });
} catch (e) { } catch (e) {
...@@ -114,7 +114,6 @@ try { ...@@ -114,7 +114,6 @@ try {
try { try {
nfcOmaReaderList = nfcSEService.getReaders(); nfcOmaReaderList = nfcSEService.getReaders();
if (nfcOmaReaderList != null && nfcOmaReaderList.length > 0) { if (nfcOmaReaderList != null && nfcOmaReaderList.length > 0) {
nfcOmaReader = this.nfcOmaReaderList[0];
console.log("get reader successfully"); console.log("get reader successfully");
} else { } else {
console.log("get reader failed"); console.log("get reader failed");
...@@ -205,7 +204,6 @@ import secureElement from '@ohos.secureElement'; ...@@ -205,7 +204,6 @@ import secureElement from '@ohos.secureElement';
let nfcSEService = null; let nfcSEService = null;
this.result = "version: "
try { try {
// refer to newSEService for this.nfcSEService // refer to newSEService for this.nfcSEService
console.log("version: " + nfcSEService.getVersion()); console.log("version: " + nfcSEService.getVersion());
...@@ -349,7 +347,7 @@ try { ...@@ -349,7 +347,7 @@ try {
```js ```js
import secureElement from '@ohos.secureElement'; import secureElement from '@ohos.secureElement';
nfcOmaReader = null; let nfcOmaReader = null;
try { try {
// refer to SEService.getReaders for this.nfcOmaReader // refer to SEService.getReaders for this.nfcOmaReader
...@@ -584,10 +582,11 @@ import secureElement from '@ohos.secureElement'; ...@@ -584,10 +582,11 @@ import secureElement from '@ohos.secureElement';
let nfcOmaSession = null; let nfcOmaSession = null;
let nfcOmaChannel = null; let nfcOmaChannel = null;
let aidArray = [720, 1080];
try { try {
// refer to Reader.openSession for this.nfcOmaSession // refer to Reader.openSession for this.nfcOmaSession
let getPromise = nfcOmaSession.openBasicChannel(this.aidArray); let getPromise = nfcOmaSession.openBasicChannel(aidArray);
getPromise.then((channel) => { getPromise.then((channel) => {
nfcOmaChannel = channel; nfcOmaChannel = channel;
console.log("openBasicChannel1 get channel successfully"); console.log("openBasicChannel1 get channel successfully");
...@@ -737,7 +736,6 @@ openBasicChannel(aid: number[], p2:number, callback: AsyncCallback\<Channel>): v ...@@ -737,7 +736,6 @@ openBasicChannel(aid: number[], p2:number, callback: AsyncCallback\<Channel>): v
```js ```js
import secureElement from '@ohos.secureElement'; import secureElement from '@ohos.secureElement';
let nfcOmaSession = null; let nfcOmaSession = null;
let nfcOmaChannel = null; let nfcOmaChannel = null;
let aidArray = [720, 1080]; let aidArray = [720, 1080];
...@@ -915,8 +913,9 @@ if (nfcOmaSession) { ...@@ -915,8 +913,9 @@ if (nfcOmaSession) {
}).catch ((err) => { }).catch ((err) => {
console.log("openLogicChannel3 exception"); console.log("openLogicChannel3 exception");
}) })
} catch (e) { } catch (e) {
console.log("openLogicChannel3 exception:" + e.message); console.log("openLogicChannel3 exception:" + e.message);
}
} }
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册