• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.nfc.cardEmulation (标准NFC-cardEmulation)(系统接口)
2
3<!--Kit: Connectivity Kit-->
4<!--Subsystem: Communication-->
5<!--Owner: @amunra03-->
6<!--Designer: @wenxiaolin-->
7<!--Tester: @zs_111-->
8<!--Adviser: @zhang_yixin13-->
9
10本模块主要提供NFC卡模拟业务,包括判断支持哪种卡模拟类型,HCE卡模拟的业务实现等。
11HCE(Host Card Emulation),称为基于主机的卡模拟,表示不依赖安全单元芯片,应用程序模拟NFC卡片,可以通过NFC服务和NFC读卡器通信。
12
13> **说明:**
14>
15> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。<br>
16> 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.nfc.cardEmulation (标准NFC-cardEmulation)](js-apis-cardEmulation.md)。
17
18
19## 导入模块
20
21```
22import { cardEmulation } from '@kit.ConnectivityKit';
23```
24
25## getPaymentServices<sup>11+</sup>
26
27getPaymentServices(): [AbilityInfo](../apis-ability-kit/js-apis-bundleManager-abilityInfo.md)[]
28
29获取所有支付类型的服务列表。如果应用程序声明支持HCE功能,并且声明了"payment-aid",则会包含在列表里面,参考[HCE卡模拟和AID列表的声明定义](js-apis-cardEmulation.md#hce卡模拟和aid列表的声明定义)。
30
31**系统接口:** 此接口为系统接口。
32
33**系统能力:** SystemCapability.Communication.NFC.CardEmulation
34
35**需要权限:** ohos.permission.NFC_CARD_EMULATION
36
37**返回值:**
38
39| **类型**  | **说明**                               |
40| ------- | ------------------------------------ |
41| [AbilityInfo](../apis-ability-kit/js-apis-bundleManager-abilityInfo.md)[] | 返回所有支付类型的服务。 |
42
43**错误码**:
44
45以下错误码的详细介绍请参见[NFC错误码](errorcode-nfc.md)。
46
47| 错误码ID | 错误信息 |
48| -------- | ---------------------------- |
49|201 | Permission denied.                 |
50|202 | Non-system applications are not allowed to use system APIs. |
51|801 | Capability not supported.          |
52
53**示例:**
54```js
55import { cardEmulation } from '@kit.ConnectivityKit';
56
57let paymentServices = cardEmulation.getPaymentServices();
58if (paymentServices == undefined || paymentServices.length == 0) {
59  console.log('paymentServices is null.');
60}
61
62```
63
64