title: NfcB

sidebar_label: NfcB

NfcB 标签

支持情况:NfcB - 图1 NfcB - 图2 NfcB - 图3

参考文档

方法

close

断开连接

支持情况:NfcB - 图4 NfcB - 图5 NfcB - 图6

参考文档

  1. (option?: Option) => Promise<TaroGeneral.NFCError>
参数 类型
option Option

connect

连接 NFC 标签

支持情况:NfcB - 图7 NfcB - 图8 NfcB - 图9

参考文档

  1. (option?: Option) => Promise<TaroGeneral.NFCError>
参数 类型
option Option

getMaxTransceiveLength

获取最大传输长度

支持情况:NfcB - 图10 NfcB - 图11 NfcB - 图12

参考文档

  1. (option?: Option) => Promise<TaroGeneral.NFCError>
参数 类型
option Option

isConnected

检查是否已连接

支持情况:NfcB - 图13 NfcB - 图14 NfcB - 图15

参考文档

  1. (option?: Option) => Promise<TaroGeneral.NFCError>
参数 类型
option Option

setTimeout

设置超时时间

支持情况:NfcB - 图16 NfcB - 图17 NfcB - 图18

参考文档

  1. (option?: Option) => Promise<TaroGeneral.NFCError>
参数 类型
option Option

transceive

发送数据

支持情况:NfcB - 图19 NfcB - 图20 NfcB - 图21

参考文档

  1. (option?: Option) => Promise<TaroGeneral.NFCError>
参数 类型
option Option

参数

close

Option

参数 类型 必填 说明
complete (res: TaroGeneral.NFCError) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.NFCError) => void 接口调用失败的回调函数
success (res: TaroGeneral.NFCError) => void 接口调用成功的回调函数

connect

Option

参数 类型 必填 说明
complete (res: TaroGeneral.NFCError) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.NFCError) => void 接口调用失败的回调函数
success (res: TaroGeneral.NFCError) => void 接口调用成功的回调函数

getMaxTransceiveLength

Option

参数 类型 必填 说明
complete (res: TaroGeneral.NFCError) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.NFCError) => void 接口调用失败的回调函数
success (result: SuccessCallbackResult) => void 接口调用成功的回调函数

SuccessCallbackResult

参数 类型 说明
length number 最大传输长度

isConnected

Option

参数 类型 必填 说明
complete (res: TaroGeneral.NFCError) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.NFCError) => void 接口调用失败的回调函数
success (res: TaroGeneral.NFCError) => void 接口调用成功的回调函数

setTimeout

Option

参数 类型 必填 说明
timeout number 设置超时时间 (ms)
complete (res: TaroGeneral.NFCError) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.NFCError) => void 接口调用失败的回调函数
success (res: TaroGeneral.NFCError) => void 接口调用成功的回调函数

transceive

Option

参数 类型 必填 说明
transceive ArrayBuffer 需要传递的二进制数据
complete (res: TaroGeneral.NFCError) => void 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: TaroGeneral.NFCError) => void 接口调用失败的回调函数
success (result: SuccessCallbackResult) => void 接口调用成功的回调函数

SuccessCallbackResult

参数 类型
data ArrayBuffer

API 支持度

API 微信小程序 H5 React Native
NfcB ✔️
NfcB.close ✔️
NfcB.connect ✔️
NfcB.getMaxTransceiveLength ✔️
NfcB.isConnected ✔️
NfcB.setTimeout ✔️
NfcB.transceive ✔️