【发布时间】:2023-01-19 23:43:29
【问题描述】:
我正在尝试做一个卡片模拟;
- 读卡到手机
- 将手机用作NFC卡....
我愿意听取任何有助于我做到这一点的图书馆建议。
我的代码就像; (它没有回应)
import React from 'react'; import { View, Text, StyleSheet, Button } from 'react-native'; import { HceTools } from 'react-native-nfc-sdk'; export default function App () { const hce = new HceTools(); const [isTagRead, setIsTagRead] = React.useState('No'); const emulate = () => { hce.startEmulation( {content: 'Hello World!', writable: false}, () => { setTagIsRead('Yes!'); setTimeout(() => setIsTagRead('No'), 5000); } ) } return ( <View> <Button onPress={emulate} title="EMULATE NFC TAG" /> <Text>Was the tag read? {isTagRead}</Text> </View> ); }我尝试了块代码,但它没有响应
【问题讨论】:
标签: react-native nfc hce