DEV Community

HarmonyOS
HarmonyOS

Posted on

NFC HCE Service Not Triggered When Tag Is Detected

Read the original article:NFC HCE Service Not Triggered When Tag Is Detected

Problem Description

The HCE (Host Card Emulation) service is not triggered when the user taps their device to an NFC reader. The reader shows "No card detected."

Background Knowledge

  • NFC HCE allows an application to emulate a smart card.
  • For the service to be triggered, the config.json must declare the HCE service and match the AID (Application Identifier) expected by the reader.
  • HarmonyOS requires ohos.permission.NFC_CARD_EMULATION permission.

Troubleshooting Process

  1. Verified that the device supports NFC and that NFC is enabled in system settings.
  2. Checked logs using Device Log tool → confirmed that no HCE service was started on tap.
  3. Inspected config.json and noticed the AID field did not match the reader’s AID.
  4. Confirmed that the ohos.permission.NFC_CARD_EMULATION was missing from permissions.

Analysis Conclusion

The issue was caused by two misconfigurations:

  • The declared AID in config.json did not match the reader’s expected AID.
  • The required ohos.permission.NFC_CARD_EMULATION was missing, preventing the service from being launched.

Solution

  • Updated config.json with the correct AID value provided by the NFC terminal vendor.

  • Added the following permission in config.json:

"requestPermissions": [ { "name": "ohos.permission.NFC_CARD_EMULATION" } ]

Verification Result

After updating the configuration, the HCE service was successfully triggered when tapping the NFC terminal. The reader correctly recognized the emulated card. Tested on two different HarmonyOS devices.

Related Documents or Links

Written by Jeorge Kiryienko

Top comments (0)