harmony 鸿蒙@ohos.nfc.cardEmulation (Standard NFC Card Emulation) (System API)

  • 2025-06-12
  • 浏览 (3)

@ohos.nfc.cardEmulation (Standard NFC Card Emulation) (System API)

The cardEmulation module implements Near-Field Communication (NFC) card emulation. You can use the APIs provided by this module to determine the card emulation type supported and implement Host Card Emulation (HCE). HCE provides card emulation that does not depend on a secure element. It allows an application to emulate a card and communicate with an NFC card reader through the NFC service.

NOTE

The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. This topic describes only the system APIs provided by the module. For details about its public APIs, see @ohos.nfc.cardEmulation (Standard NFC Card Emulation).

Modules to Import

import { cardEmulation } from '@kit.ConnectivityKit';

getPaymentServices11+

getPaymentServices(): AbilityInfo[]

Obtains all payment services. If an application declares the support for the HCE feature and payment-aid, the application is contained in the payment service list. For details, see HCE and AID Declaration.

System API: This is a system API.

System capability: SystemCapability.Communication.NFC.CardEmulation

Required permissions: ohos.permission.NFC_CARD_EMULATION

Return value

Type Description
AbilityInfo[] List of payment services obtained.

Error codes

For details about the error codes, see NFC Error Codes.

ID Error Message
201 Permission denied.
202 Non-system applications are not allowed to use system APIs.
801 Capability not supported.

Example

import { cardEmulation } from '@kit.ConnectivityKit';

let paymentServices = cardEmulation.getPaymentServices();
if (paymentServices == undefined||paymentServices.length == 0) {
  console.log('paymentServices is null.');
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Connectivity Kit (Short-Range Communication Service)

harmony 鸿蒙Bluetooth

harmony 鸿蒙Wifi

harmony 鸿蒙Bluetooth Error Codes

harmony 鸿蒙NFC Error Codes

harmony 鸿蒙SecureElement Error Codes

harmony 鸿蒙Wi-Fi Error Codes

harmony 鸿蒙@ohos.bluetooth.a2dp (Bluetooth A2DP Module) (System API)

harmony 鸿蒙@ohos.bluetooth.a2dp (Bluetooth A2DP Module)

harmony 鸿蒙@ohos.bluetooth.access (Bluetooth Access Module) (System API)

0  赞