# wx.sendHCEMessage(Object object)
Start from base library version 1.7.0. Please remaining backward compatible.
with Promise style call: Supported
Mini Program plugin: Support, need to Mini Program base library version no less than 2.1.0
send NFC News. Only available on Android.
# parameter
# Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
data | ArrayBuffer | yes | Binary data | |
success | function | no | Interface calls the successful callback function | |
fail | function | no | Interface calls failed callback functions | |
complete | function | no | Interface calls the end of the callback function (call success or failure will be executed) |
# error
Error code | Error message | Introductions |
---|---|---|
0 | ok | normal |
13000 | Current device does not support NFC | |
13001 | Current device supports NFC, but the system NFL switch is not turned on | |
13002 | Current device supports NFC, but not HCE | |
13003 | AID list parameter format error | |
13004 | WeChat is not set to default NFC payment app | |
13005 | Illegal instruction returned | |
13006 | Failed to register AID |
# sample code
const buffer = new ArrayBuffer(1)
const dataView = new DataView(buffer)
dataView.setUint8(0, 0)
wx.startHCE({
success (res) {
wx.onHCEMessage(function(res) {
if (res.messageType === 1) {
wx.sendHCEMessage({data: buffer})
}
})
}
})