revtel / react-native-nfc-manager

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

Alert when disconnecting NFC card #674

Closed crojasv90 closed 5 months ago

crojasv90 commented 9 months ago

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); }; }, [])

alan-dev-hk commented 9 months ago

Hey, man Could you find the solution?

crojasv90 commented 9 months ago

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

alan-dev-hk commented 9 months ago

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

alan-dev-hk commented 9 months ago

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'

github-actions[bot] commented 6 months ago

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] commented 5 months ago

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