revtel / react-native-nfc-manager

React Native NFC module for Android & iOS
MIT License
1.32k stars 312 forks source link

Cancel technology request not properly cancelling sessions #724

Closed giuliobracci closed 1 month ago

giuliobracci commented 1 month ago

Hi there,

I was testing why the cancelTechnologyRequest method was causing issues, especially when simulating this flow on iOS:

1 - Bind the requestTechnology method to an onPress handler 2 - Press cancel and wait for the cancelTechnologyRequest completion (disable the button untill the request is succesfully handled) 3 - Repeat the process.

You will notice that randomly between the second/third/fourth/fifth try you will get stuck and the technology request does not get cancelled properly. @whitedogg13 I managed to reproduce the issue also on nfc-rewriter

I managed to solve the issue by setting the session and the tagSession to nil after calling the invalidation methods. I'm opening a PR with the patch, I'm not an expert of Objective C, so that it with a grain a salt, but I tested it in the current app we're developing and it works. I wonder if we should do something similar also for the event based approch.