WeChat small program NFC
May 18, 2021
WeChat Mini Program Development Document
Table of contents
Nfc
Supports HCE (host-based card simulation) mode, which simulates Android phones as physical smart cards.
NFC read and write is supported, i.e. the phone is used as a card reader.
-
Models: NFC-enabled phones with Android 5.0 and above
-
Card range: CPU cards that comply with ISO 14443-4
-
Reader/Writer mode is supported, i.e. passive NFC labels and stickers are read and/or written by NFC devices.
-
Models: NFC-enabled phones with Android 5.0 and above
-
Scope of application: NFC-A (ISO 14443-3A)/NFC-B (ISO 14443-3B)/NFC-F (JIS 6319-4)/NFC-V (ISO) 15693)/ISO-DEP (ISO 14443-4) standard read and write (partial Android phone) supports the reading and writing of the MFARE Classic/MIFARE Ultralight label to support the reading and writing of NDF data on NFC labels in NDF format
Basic processes
In the past, NFC-A cards were written to apdu instructions as an example
-
Call wx.getNFCAdapter() to get the NFC adapter instance
-
Call NFCAdapter.onDiscovered (function callback) to register a sticker to listen for callbacks
-
Call NFCAdapter.startDiscovery to start listening to the sticker
-
The sticker, onDiscovered callback, matches the techs field of the onDiscovered callback res object to the card support NFC-A standard by obtaining the NFCA instance through NFCAdapter.getNfcA().
-
Use the NfcA instance to read and write call NfcA.connect() and NFC card establishment connection call NfcA.transceive (Object object) to the NFC card to write the apdu instruction and receive the card to return data read and write, call NfcA.close() disconnect
-
Call NFCAdapter.stopDiscovery (Object object) to end the listening sticker