react-native-nfc-manager icon indicating copy to clipboard operation
react-native-nfc-manager copied to clipboard

cannot convert undefined value to object.

Open aasharck opened this issue 1 year ago • 8 comments

Whenever I try to read an NFC tag/card. It shows me this error cannot convert undefined value to object.

Any solution for this?

aasharck avatar Oct 24 '23 08:10 aasharck

Maybe you are using expo Go and you do not have the plugin configured in the app.json. Expo GO In my case, only NFC works for me when I build the APK, but I use expo GO, with CLI it is not necessary to build.

crojasv90 avatar Oct 26 '23 13:10 crojasv90

Nop. I am using react native cli. Also, I am trying to read from another device using HCE. One phone is Android 13 and the other is Android 10. I am able to read from Android 13 by using the Android 10 device, but not the other way around.

Not sure why

aasharck avatar Oct 26 '23 13:10 aasharck

It seems to me that it is an NFC permissions issue. Check that part for the android version.

crojasv90 avatar Oct 26 '23 14:10 crojasv90

Thanks, I checked the permissions, But I don't see any problem there. NFC is allowed for the app on both phones

aasharck avatar Oct 26 '23 14:10 aasharck

Are you getting this when trying to access the array ndefMessage on the returned tag? I have found that even though the TagEvent interface says it will always return an ndefMessage: NdefMessage[] it sometimes (~10-20%) does not actually contain the ndefMessage key.

For me this seems to happen randomly, not in any predictable sort of way. I assume it's some kind of read error?

Dug a little into the source and it seems like at least on ios, if there's an error reading the ndefMessage it doesn't propagate the error but just returns the tag without the message (like I'm seeing):

if (!error) {
   [rnTag setObject:[NfcManager convertNdefMessage:ndefMessage] forKey:@"ndefMessage"];
}

callback(@[[NSNull null], rnTag]);

johncantrell97 avatar Oct 26 '23 21:10 johncantrell97

Yea exactly.

When I tried console logging "tag" variable, In the types attribute, ndef type was no found. Not sure why?

aasharck avatar Oct 26 '23 21:10 aasharck

I believe it's due to an error reading the tag in native code that doesn't bubble up to the javascript.

johncantrell97 avatar Oct 26 '23 22:10 johncantrell97

#692 @crojasv90 @johncantrell97 can you please help me?

kamatil-dev avatar Jan 14 '24 14:01 kamatil-dev

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Apr 14 '24 02:04 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Apr 30 '24 01:04 github-actions[bot]