易语言可以做网站,江西机场建设集团网站,网站数据统计怎么做,怎么修改网站排版有源标签 说明#xff1a; 本模块首批接口从API version 8开始支持。后续版本的新增接口#xff0c;采用上角标单独标记接口的起始版本。 导入模块
import connectedTag from ohos.connectedTag;connectedTag.init
init(): boolean
初始化有源标签芯片。
需要权限#…有源标签 说明 本模块首批接口从API version 8开始支持。后续版本的新增接口采用上角标单独标记接口的起始版本。 导入模块
import connectedTag from ohos.connectedTag;connectedTag.init
init(): boolean
初始化有源标签芯片。
需要权限ohos.permission.NFC_TAG
系统能力SystemCapability.Communication.ConnectedTag 返回值 类型说明booleantrue:初始化成功 false:初始化失败。
connectedTag.uninit
uninit(): boolean
卸载有源标签芯片资源。
需要权限ohos.permission.NFC_TAG
系统能力SystemCapability.Communication.ConnectedTag 返回值 类型说明booleantrue:卸载操作成功 false:卸载操作失败。
connectedTag.readNdefTag
readNdefTag(): Promise
读取有源标签内容使用promise方式作为异步方法。
需要权限ohos.permission.NFC_TAG
系统能力SystemCapability.Communication.ConnectedTag 返回值 类型说明Promise返回读取有源标签内容。 示例 import connectedTag from ohos.connectedTag;connectedTag.readNdefTag().then(result {console.log(promise recv ndef response: result);
});connectedTag.readNdefTag
readNdefTag(callback: AsyncCallback): void
读取有源标签内容使用callback方式作为异步方法。
需要权限ohos.permission.NFC_TAG
系统能力SystemCapability.Communication.ConnectedTag 参数 参数名类型必填说明callbackAsyncCallback是读取有源标签内容回调函数。 示例 import connectedTag from ohos.connectedTag;connectedTag.readNdefTag(result {console.log(callback recv ndef response: result);
});connectedTag.writeNdefTag
writeNdefTag(data: string): Promise
写入内容到有源标签使用promise方式作为异步方法。
需要权限ohos.permission.NFC_TAG
系统能力SystemCapability.Communication.ConnectedTag 参数 参数名类型必填说明datastring是有源标签内容, 长度最大是1024个字节。 返回值 类型说明Promise无返回值。 示例 import connectedTag from ohos.connectedTag;writeNdefTag.write(010203).then((value) {// 事件写入正常console.log(success to write event: ${value});}).catch((err) {// 事件写入异常console.error(failed to write event because ${err.code});});connectedTag.writeNdefTag
writeNdefTag(data: string, callback: AsyncCallback): void
写入内容到有源标签使用callback方式作为异步方法。
需要权限ohos.permission.NFC_TAG
系统能力SystemCapability.Communication.ConnectedTag 参数 参数名类型必填说明datastring是有源标签内容, 长度最大是1024个字节。callbackAsyncCallback是读取有源标签内容回调函数。 示例 import connectedTag from ohos.connectedTag;connectedTag.writeNdefTag(010203, (err, value) {if (err) {// 事件写入异常console.error(failed to write event because ${err.code});return;}// 事件写入正常console.log(success to write event: ${value});
});connectedTag.on(‘notify’)
on(type: “notify”, callback: Callback): void
注册NFC场强状态事件。
需要权限ohos.permission.NFC_TAG
系统能力SystemCapability.Communication.ConnectedTag 参数 参数名类型必填说明typestring是固定填notify字符串callbackCallback是状态改变回调函数。 状态改变事件的枚举。 枚举值说明0NFC离场事件1NFC进场事件
connectedTag.off(‘notify’)
off(type: “notify”, callback?: Callback): void
取消NFC场强状态事件的注册。
需要权限ohos.permission.NFC_TAG
系统能力SystemCapability.Communication.ConnectedTag 参数 参数名类型必填说明typestring是固定填notify字符串callbackCallback否状态改变回调函数。如果callback不填将“去注册”该事件关联的所有回调函数。 示例 import connectedTag from ohos.connectedTag;var NFC_RF_NOTIFY notify;var recvNfcRfNotifyFunc result {console.info(nfc rf receive state: result);
}// Register event
connectedTag.on(NFC_RF_NOTIFY, recvNfcRfNotifyFunc);// Unregister event
connectedTag.off(NFC_RF_NOTIFY, recvNfcRfNotifyFunc);NfcRfType
表示NFC场强状态的枚举。
名称默认值说明NFC_RF_LEAVE0NFC离场事件NFC_RF_ENTER1NFC进场事件