-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] AppState background triggered while scanning nfc chip #437
Comments
@buekera That is happening because of how react native sees/defines background and foreground states. That false report happens really fast, what you could do is to measure time between background/foreground and to ignore those false reports. But to measure it in background you need this package since when react native app goes to background state it is paused and code will not execute until you are back in the app again, so measuring is not possible without running some code in background. For example setTimeout or setInterval. Package for running background code: https://github.com/ocetnik/react-native-background-timer I've already recently reported this to react-native community repo and it was already reported couple years ago, I think in 2018 but old report was closed due to inactivity. You can see they are not interested in this issue: |
I "fixed" it by measuring how long "background" state was on until "active" state was back on.
|
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. |
This issue was closed because it has been stalled for 5 days with no activity. |
I fixed it similarly to the solution provided above but just set the difference to 500 ms because it usually takes 20-40 ms if its the NFC triggering the state changes and it works for me.
|
On Android, the To handle this, I created a package that implements the Android Lifecycle API for React Native: https://github.com/douglasjunior/react-native-applifecycle
|
Hey there, I just noticed some odd behavior while scanning nfc chips.
The moment you put your nfc chip to the phone and the scanner detects it the AppState changes from
active
tobackground
back toactive
again.Due to this behavior some other parts which listen to the AppStage change behave strangely. Is there any way to work around this or might this even be a bug?
OS: Android
tested nfc manager versions: 3.7.0 - 3.10.0
Code:
So when putting a nfc chip to the scanner the following logs within a split second:
Regards
The text was updated successfully, but these errors were encountered: