Using HMS Wear Engine, you can communicate between Android and the watch app. To make payment via NFC, you can send the tokens you have to the watch with this service and communicate with the POS terminal via the watch.
- Wear Engine integration for Lite-Wearable
- Encrypt & Decrypt Keys with HUKS (HarmonyOS Universal KeyStore)
- NFC Transactions between Watch and POS Terminal
- JavaScript programming language
- HarmonyOS Operating System
- HMS Wear Engine
- HarmonyOS Universal KeyStore (HUKS)
The following functions are used in index.js class.
The initCardEmulation function checks the NFC card emulation capabilities of the device and whether a particular application is the default service for NFC card emulation.
- It provides the necessary prerequisites for NFC card emulation by calling the initCardEmulation function.
- Initializes NFC card emulation by creating an instance of the cardEmulation.HceService class.
- Starts NFC card emulation with a specific application name and NFC payment AID via the start method.
- By adding an "hceCmd" event to the hceService object, the NFC card emulation defines a callback function that will run when a command is sent to the device. This function processes the incoming APDU command by calling the handleApdu function and generates an appropriate response.
The sendResponse function transmits a response generated by NFC card emulation. This function transmits the generated response to the device via the hceService.transmit method.
This function checks the match between APDU commands received by the NFC card emulation and predefined APDU commands.
The handleApdu function processes an APDU (Smart Card Commands) command received by the NFC card emulation. This function compares the incoming APDU command with predefined commands and generates an appropriate response.
This is the part where the necessary operations are performed according to the button clicked and a toast message is displayed to the user on the screen according to the result of the operation.
- HarmonyOS Design Guide: https://developer.huawei.com/consumer/en/doc/design-guides-V1/components-0000001053459781-V1
- HarmonyOS Universal KeyStore (HUKS) Overview: https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V2/huks-overview-0000001496554665-V2
- HUAWEI Wear Engine SDK Integration: https://developer.huawei.com/consumer/en/doc/connectivity-Guides/integrating-fitnesstwatch-sdk-0000001052859174
- HUAWEI Wear Engine Service Introduction: https://developer.huawei.com/consumer/en/doc/connectivity-Guides/service-introduction-0000000000018585