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

Alert when disconnecting NFC card

Open crojasv90 opened this issue 2 years ago • 5 comments

Greetings. I need to show one alert when an NFC card is connected and another when it is disconnected. I can't achieve the disconnection, I tried with setEventListener with the sessionClosed event, but it never shows the disconnection. Does anyone know how to obtain the event?

Example useEffect(() => { NfcManager.setEventListener(NfcEvents.DiscoverTag, tag => { alert("NFC Tag found"); }); NfcManager.setEventListener(NfcEvents.SessionClosed, () => { alert("Session closed"); }); return () => { NfcManager.setEventListener(NfcEvents.DiscoverTag, null); NfcManager.setEventListener(NfcEvents.SessionClosed, null); }; }, [])

crojasv90 avatar Oct 26 '23 13:10 crojasv90

Hey, man Could you find the solution?

alan-dev-hk avatar Nov 07 '23 15:11 alan-dev-hk

I'm still looking for a solution. Do you have any idea? Or do you know if the technology supports it?

crojasv90 avatar Nov 07 '23 16:11 crojasv90

No, unfortunately. I'm still looking for some solution as well. In case I resolve it, I post it here.

alan-dev-hk avatar Nov 07 '23 17:11 alan-dev-hk

Hey, maybe I finded the solution. NfcManager.setEventListener(NfcEvents.StateChanged, data => this.CallbackDisconect(data)); So, the NfcEvents.StateChanged will fire when you turn on or turn of the NFC. So, maybe you can work with it.

The responses are: 'on' | 'turning_on' | 'off' | 'turning_off'

alan-dev-hk avatar Nov 07 '23 17:11 alan-dev-hk

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 Feb 06 '24 01:02 github-actions[bot]

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

github-actions[bot] avatar Feb 21 '24 01:02 github-actions[bot]