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.jsonmust declare the HCE service and match the AID (Application Identifier) expected by the reader. - HarmonyOS requires
ohos.permission.NFC_CARD_EMULATIONpermission.
Troubleshooting Process
- Verified that the device supports NFC and that NFC is enabled in system settings.
- Checked logs using Device Log tool → confirmed that no HCE service was started on tap.
- Inspected
config.jsonand noticed the AID field did not match the reader’s AID. - Confirmed that the
ohos.permission.NFC_CARD_EMULATIONwas missing from permissions.
Analysis Conclusion
The issue was caused by two misconfigurations:
- The declared AID in
config.jsondid not match the reader’s expected AID. - The required
ohos.permission.NFC_CARD_EMULATIONwas missing, preventing the service from being launched.
Solution
Updated
config.jsonwith 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.
Top comments (0)