NFC 功能中的wx.onHCEMessage方法不执行 获取不到数据?
wx.startHCE({
aid_list,
success: (res) => {
console.log("startHCE");
uni.showToast({ title: "startHCE", duration: 2000 });
wx.getHCEState({
success(res) {
console.log(res);
wx.showToast({ title: "getHCEState" + res.errCode, duration: 2000 });
wx.onHCEMessage((res) => {
console.log("onHCEMessage", res);
wx.showToast({ title: "onHCEMessage", duration: 2000 });
if (res.messageType === 1) {
console.log("res.messageType === 1");
console.log(res.data);
const dataView = new DataView(res.data);
dataView.setUint8(0, 0);
console.log(res.data);
wx.sendHCEMessage({
data: res.data,
success: (res) => {
console.log("sendHCEMessage" + res.errMsg);
},
fail: (res) => {
console.log("sendHCEMessage失败" + res.errMsg);
}
})
} else {
console.log(res.reason);
}
})
},
fail(res) {
console.log(res.errMsg);
}
})
},
fail(res) {
console.log(res);
wx.showToast({ title: res.errMsg, duration: 2000 });
}
})
这是我写的示例代码 运行到wx.onHCEMessage后就不执行 有哪里不正确请说明下 急 项目需要