【问题标题】:How to emulate phone via nfc/hce (React Native) (Android)如何通过 nfc/hce (React Native) 模拟手机 (Android)
【发布时间】:2023-01-19 23:43:29
【问题描述】:

我正在尝试做一个卡片模拟;

  1. 读卡到手机
  2. 将手机用作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


    【解决方案1】:

    尝试将此库用于 HCE 仿真 https://github.com/appidea/react-native-hce

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-10
      • 1970-01-01
      • 2023-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多