![](/img/trans.png)
[英]NFC using foregroundDispatch in react-native and android
[英]How to emulate phone via nfc/hce (React Native) (Android)
我正在嘗試做一個卡片模擬;
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>
);
}
我嘗試了塊代碼,但它沒有響應
嘗試將此庫用於 HCE 仿真https://github.com/appidea/react-native-hce 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.