NFC 功能中的wx.onHCEMessage方法不执行 获取不到数据?
发布于 5 年前 作者 weihou 1398 次浏览 来自 官方Issues
  wx.startHCE({
    aid_list,
    success(res) => {
      console.log("startHCE");
      uni.showToast({ title"startHCE"duration2000 });
      wx.getHCEState({
        success(res) {
          console.log(res);
          wx.showToast({ title"getHCEState" + res.errCode, duration2000 });
          wx.onHCEMessage((res) => {
            console.log("onHCEMessage", res);
            wx.showToast({ title"onHCEMessage"duration2000 });
            if (res.messageType === 1) {
              console.log("res.messageType === 1");
              console.log(res.data);
              const dataView = new DataView(res.data);
              dataView.setUint8(00);
              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, duration2000 });
    }
  })
这是我写的示例代码  运行到wx.onHCEMessage后就不执行   有哪里不正确请说明下   急 项目需要
回到顶部