我正在尝试使用 react-native-NFC-Manager 在我的 react-native 应用程序中添加 NFC 功能,它工作正常。但问题是我第一次无法读取/写入 NFC 卡。第一次,我需要使用 NFC Tool 应用程序编写一个新标签,将“NdefFormatable”转换为“Ndef”,否则我无法读取/写入 NFC 卡
我用这段代码写数据:
await NfcManager.requestTechnology(NfcTech.Ndef, {
alertMessage: 'Ready to write some NDEF',
});
const bytes = Ndef.encodeMessage([Ndef.textRecord('Hello NFC')]);
if (bytes) {
await NfcManager.ndefHandler // Step2
.writeNdefMessage(bytes); // Step3
if (Platform.OS === 'ios') {
await NfcManager.setAlertMessageIOS('Successfully write NDEF');
}
}
这个问题有什么解决办法吗?