Closed filipboev closed 8 months ago
Hello @filipboev,
Thank you for bringing this issue to our attention. It looks like you've provided a viable solution to the problem, which is commendable!
We'll conduct thorough testing on our end and incorporate it into the upcoming release. We'll keep you informed once the release is live.
Best regards.
Noticed here that you're subclassing
RCTEventEmitter
https://github.com/Purchasely/Purchasely-ReactNative/blob/be5075c9ab123bff0cd080168a78b8f81647de5c/purchasely/ios/PurchaselyRN.h#L11But in PurchaselyRN.m there isn't any way to stop events from being emitted if there are no active listeners yet. https://github.com/Purchasely/Purchasely-ReactNative/blob/be5075c9ab123bff0cd080168a78b8f81647de5c/purchasely/ios/PurchaselyRN.m#L16
Which tends to lead to exceptions like these:
I noticed this happening often on a debug build, but my guess is it might also happen on a release build since I've seen other native modules have the same problem in the past.
React Native has these two methods from
RCTEventEmitter
that you can override to handle the cases where you have no listeners yet.So something like this should do the trick and won't expend resources unnecessarily.
Environment