revtel / react-native-nfc-manager

React Native NFC module for Android & iOS
MIT License
1.33k stars 317 forks source link

Cannot implement nfc manager in expo #673

Closed christianevan closed 9 months ago

christianevan commented 9 months ago

async function readNdef() { NfcManager.start(); try { // register for the NFC tag with NDEF in it await NfcManager.requestTechnology(NfcTech.Ndef); console.log('Testing'); // the resolved tag object will contain ndefMessage property const tag = await NfcManager.getTag(); if (tag) { console.warn('Tag found', tag); } else { console.warn('No NDEF tag found'); } } catch (ex) { console.warn('Oops!', ex); throw ex; } finally { ()=>NfcManager.cancelTechnologyRequest(); } }

I just followed the implemented code of react native nfc manager. But it always throws an error: "TypeError: Cannot convert null value to object". I use expo in my project. As you can see in my code, the console log is never shown.

nfuenmamelt commented 9 months ago

@christianevan How do you solve this issue, I'm having the same using expo I'm trying to read or write using "await NfcManager.requestTechnology(NfcTech.Ndef);" but never end this method.

christianevan commented 9 months ago

@christianevan How do you solve this issue, I'm having the same using expo I'm trying to read or write using "await NfcManager.requestTechnology(NfcTech.Ndef);" but never end this method.

I haven't resolved it yet. But I guess the easiest way is to make a custom native module for the NFC reader and then use it in Expo.

You can check this: https://docs.expo.dev/modules/native-module-tutorial

kamatil-dev commented 7 months ago

any update? @christianevan @nfuenmamelt