Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-android-nfc
Advanced tools
Readme
npm i react-android-nfc
react-native link react-android-nfc
import {NfcAdapter, NdefRecord } from 'react-android-nfc'
常量名 | 类型 | 值 | 说明 |
---|---|---|---|
isAvailable | boolean | 支持NFC的手机值为true,否则为false | 使用NfcAdapter模块的函数方法前必须使用该常量判断手机是否具备NFC功能 |
STATE_ON | string | - | 手机NFC开关状态常量 |
STATE_OFF | string | - | 手机NFC开关状态常量 |
STATE_TURNING_ON | string | - | 手机NFC开关状态常量 |
STATE_TURNING_OFF | string | - | 手机NFC开关状态常量 |
FILTER_NDEF_DISCOVERED | string | - | 标签感应过滤器常量,优先级最高 |
FILTER_TECH_DISCOVERED | string | - | 标签感应过滤器常量,优先级次高 |
FILTER_TAG_DISCOVERED | string | - | 标签感应过滤器常量,优先级最低 |
TECH_NDEF | string | - | nfc技术常量,NDEF技术标准 |
TECH_NDEF_FORMATABLE | string | - | 标签技术常量,NdefFormatable技术标准 |
TECH_NFC_A | string | - | nfc技术常量,NfcA技术标准 |
TECH_NFC_B | string | - | nfc技术常量,NfcB技术标准 |
TECH_NFC_F | string | - | nfc技术常量,NfcF技术标准 |
TECH_NFC_V | string | - | nfc技术常量,NfcV技术标准 |
TECH_ISO_DEP | string | - | nfc技术常量,IsoDep技术标准 |
TECH_MIFARE_CLASSIC | string | - | nfc技术常量,MifareClassic技术标准 |
TECH_MIFARE_ULTRALIGHT | string | - | nfc技术常量,MifareUltralight技术标准 |
函数 | 参数 | 返回值 | 说明 |
---|---|---|---|
isEnable(fun) | fun:(result)=> {...} | - | result为手机nfc开关当前是否打开 |
addStateListener(fun) | fun:(state) => {...} | DeviceEventListener对象 | state为手机nfc状态,可为STATE_ON,STATE_OFF,STATE_TURNING_ON,STATE_TURNING_OFF |
removeStateListener(listener) | listener:即为addStateListener的参数对象fun | - | 该函数通常用于组件UnMount时移除listener,以防止组件卸载后仍监听事件; 代替该函数的更好做法是利用addStateListener返回的DeviceEventListener对象,调用DeviceEventListener.remove()方法 |
enableForegroundDispatchDefault() | - | - | 开启nfc前台分派系统,即应用处于前台时优先响应nfc标签,默认响应任何类型的标签 |
enableForegroundDispatch(filters:string[],techs:[string[],string[],...]) | filters:string[],标签感应过滤器数组,元素值为标签感应过滤器常量; techs:[string[],string[],...],nfc技术二维数组,元素值为nfc技术常量 | - | 若filters和techs为null,则作用与enableForegroundDispatchDefault一致; techs在过滤规则中,一维的数组间为或(||)关系,二维的字符串元素间为与(&&)关系 |
disableForegroundDispatch() | - | - | 关闭nfc前台分派系统 |
addTagDetectedListener(fun) | fun:(tag) => {...} | DeviceEventListener对象 | tag为标签信息的JSON对象 |
removeTagDetectedListener(listener) | listener:即为addTagDetectedListener的参数对象fun | - | 该函数通常用于组件UnMount时移除listener,以防止组件卸载后仍监听事件; 代替该函数的更好做法是利用addTagDetectedListener返回的DeviceEventListener对象,调用DeviceEventListener.remove()方法 |
readTagInfo() | - | - | 与addTagDetectedListener配合使用,使读取标签详细信息,若不调用该函数,则不会对标签数据进行解析,回调函数fun的tag参数默认只包含id信息 |
ignoreTagInfo() | - | - | 作用也readTagInfo相反 |
writeNdefMessage(message:object[]) | message:object[],NdefRecord对象数组,数组元素可使用NdefRecord的辅助API创建 | Promise对象 | 该函数将创建新的写数据任务进程,当感应到新的标签则开始进程,写入成功则调用Promise.resolve(true);若写进程出现异常则调用Promise.reject(e),其中e为包含了错误信息的对象 |
cancelWriteOption() | - | - | 取消已创建的写数据任务 |
函数 | 参数 | 返回值 | 说明 |
---|---|---|---|
createText(text:string) | text:文本字符串 | NdefRecord对象 | 创建文本记录 |
createUri(uri:string) | uri:uri字符串 | NdefRecord对象 | 创建Uri记录 |
createExternal(domain:string,type:string,payload:string) | domain:领域名,type:类型名,payload:有效负载 | NdefRecord对象 | 创建扩展类型记录 |
createAAR(appName:string) | appName:app的完整名 | NdefRecord对象 | 创建Android Application Record记录 |
createMime(type:string, payload:string) | type:Mime类型名,payload:有效负载 | NdefRecord对象 | 创建MIME类型记录 |
FAQs
android NFC for react-native
The npm package react-android-nfc receives a total of 0 weekly downloads. As such, react-android-nfc popularity was classified as not popular.
We found that react-android-nfc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.