Closed Nikos410 closed 3 years ago
Hi, thank you for submitting this pull request.
I have a question, is there a reason for not including the genericReceiver object in the unregisterReceivers method?
Hey Darryn,
the existing code in onHostPause()
only unregistered myEnumerateScannersBroadcastReceiver
and scannedDataBroadcastReceiver
, so I did the same in unregisterReceivers
.
If the genericReceiver
should also be unregistered I can include it in the new method.
That makes sense. I was not aware of onCatalystInstanceDestroy
but there was a similar issue raised a few months back on my demo app, i.e. it was registering a broadcast receiver multiple times during development (hot reload). I "fixed" the issue with https://github.com/darryncampbell/DataWedgeReactNative/commit/79d5325f486bae3c4cd7c45486f7ded189ca5a9c but it sounds like a superior fix would have been to do something similar to what you have done with onCatalystInstanceDestroy
.
That was where my question was coming from... if you do not include genericReceiver in onCatalystInstanceDestroy
, I think you would still end up with duplicate receivers, at least for genericReceiver.
Sorry I don't have more time to dedicate to this and answer my question but I have tested your change with my demo app & it all works so I will merge this PR.
Thanks again.
Thank you for your quick response @darryncampbell ! Could you publish the latest version on npm?
Sure, done just now: https://www.npmjs.com/package/react-native-datawedge-intents/v/0.1.7
Hey there,
when reloading the React Native bundle the receivers are not unregistered, so we end up with duplicate receivers.
This PR fixes this issue by unregistering the listeners in
onCatalystInstanceDestroy
(which is called when the React Native bundle is reloaded).I've also moved the receiver un-registration to a helper method to remove some duplicate code.