title: NfcA

sidebar_label: NfcA

NfcA 标签

支持情况:NfcA - 图1 NfcA - 图2 NfcA - 图3 NfcA - 图4

参考文档

方法

close

断开连接

支持情况:NfcA - 图5 NfcA - 图6 NfcA - 图7 NfcA - 图8

参考文档

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

connect

连接 NFC 标签

支持情况:NfcA - 图9 NfcA - 图10 NfcA - 图11 NfcA - 图12

参考文档

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

getAtqa

获取 ATQA 信息

支持情况:NfcA - 图13 NfcA - 图14 NfcA - 图15 NfcA - 图16

参考文档

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

getMaxTransceiveLength

获取最大传输长度

支持情况:NfcA - 图17 NfcA - 图18 NfcA - 图19 NfcA - 图20

参考文档

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

getSak

获取 SAK 信息

支持情况:NfcA - 图21 NfcA - 图22 NfcA - 图23 NfcA - 图24

参考文档

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

isConnected

检查是否已连接

支持情况:NfcA - 图25 NfcA - 图26 NfcA - 图27 NfcA - 图28

参考文档

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

setTimeout

设置超时时间

支持情况:NfcA - 图29 NfcA - 图30 NfcA - 图31 NfcA - 图32

参考文档

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

transceive

发送数据

支持情况:NfcA - 图33 NfcA - 图34 NfcA - 图35 NfcA - 图36

参考文档

  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 接口调用成功的回调函数

getAtqa

Option

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

SuccessCallbackResult

参数 类型 说明
atqa ArrayBuffer 返回 ATQA/SENS_RES 数据

getMaxTransceiveLength

Option

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

SuccessCallbackResult

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

getSak

Option

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

SuccessCallbackResult

参数 类型 说明
sak number 返回 SAK/SEL_RES 数据

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
NfcA ✔️ ✔️
NfcA.close ✔️ ✔️
NfcA.connect ✔️ ✔️
NfcA.getAtqa ✔️ ✔️
NfcA.getMaxTransceiveLength ✔️ ✔️
NfcA.getSak ✔️ ✔️
NfcA.isConnected ✔️ ✔️
NfcA.setTimeout ✔️ ✔️
NfcA.transceive ✔️ ✔️