-
Notifications
You must be signed in to change notification settings - Fork 86
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
[Bug]: Invariant Violation: new NativeEventEmitter() requires a non-null argument. #233
Comments
Hi @Jack-Gill-TH, Thanks for filing this issue and linking between the thread here and the one on Segment's React Native Braze partner SDK. Since it appears to be a pretty technical issue (possibly related to a race condition), would you be able to try to reproduce this in a fresh project to ensure that it isn't interfering with other parts of the app? It's pretty difficult to debug the root cause if there are many unknowns in a larger production app. Thank you! |
Hi @hokstuff thanks for getting back to me! I have set up a fresh React Native project, using the same version of RN as our project is using, and followed the Braze iOS integration steps, and I cannot reproduce the problem. I am importing BrazePlugin at the top of the App.js file and immediately adding it as a plugin, but it seems to have no problem accessing One extra odd thing is that I'm getting a linting error for the import line in my project ( I'm continuing to investigate, though I've been looking at this for a few weeks now and I'm running out of ideas 😅 Is there any kind of 'ready' state I should be waiting for before I try and import Braze? |
Thanks @Jack-Gill-TH, we'll take a deeper dive into the issue, but there shouldn't be any kind of waiting before you can use Braze in the React Native SDK. If you have followed those setup steps, your instance should be ready to go. I'm not sure about the linting error, though. It may be possible you need to reinstall it. Have you verified that the plugin appears under the file hierarchy? |
Thanks @jerielng thats's useful to know. I've definitely reinstalled it plenty of times, and I've confirmed that the plugin files definitely are in the file hierarchy where I would expect them to be. Was just wondering whether it could be connected - trying to give as much info as possible because I know it's a big ask to ask you to figure out what's wrong with a big project! |
Thanks for the confirmation, and we appreciate the information! We'll try our best to diagnose the issue, but If there's any reproduction steps you are able to come up with and share, please continue to let us know! |
@jerielng of course, I'll keep at it! My next idea is to take a close look at the settings in XCode for my project and the fresh one - maybe there's some kind of compile-order setting that's configured differently in my project? It's at least six years old so there's often bits of legacy config hiding where you'd least expect 😅 |
Some more findings: I get the same problem when I just integrate the Braze RN SDK. As soon as I add I tried making a release build with the import line in and got the same result, or rather, the app immediately crashes as opposed to showing the RN logbox. |
Thanks, @Jack-Gill-TH, one thing that might help as well: Is this a new integration? Are you able to confirm what is the earliest version that's causing this? |
Hi @jerielng - this is a new integration, we've had segment and firebase set up for a while but this is the first time we've ever included the Braze sdk. I'll do some experimentation today to see if I can find an earlier version where this isn't a problem. I've tried going down to 4.1.0 of the Braze SDK and that had the same problem, but I'll check earlier versions. |
@jerielng I've tried with 3.0.0 as well and get the exact same error. Unfortunately when I tried 2.0.0 I couldn't get XCode to create a debug build and it seemed like it was just too old and was using some no longer available Interfaces/Functions. |
Hey @Jack-Gill-TH, just wanted to follow up if you are still facing this issue in the React Native SDK? From our testing, we haven't been able to reproduce this in a fresh project, unfortunately. We've referenced the sample AppDelegate you've provided as well. This issue continues to be on our radar. Let us know if there is any additional information you have found that may be of use. |
Hi @jerielng ! Thanks for following up. In the end I decided that I needed to move on with my implementation and couldn't wait to figure out how this could be properly fixed. What I've ended up with is using This is working for me currently, and I've successfully implemented Braze identification and push notifications using the segment plugin. So I'm happy if you want to reduce the priority of this or close it as won't fix. Our app is in need of some modernisation and I expect to be involved in an initiative to bring all our dependencies up to date and maybe switch over to expo, so I'll maybe return with some info about how that goes, but that won't be for a while yet! |
Which Platforms?
iOS
Which React Native Version?
0.68.7
Which @braze/react-native-sdk SDK version?
5.2.0
Repro Rate
100%
Steps To Reproduce
Example:
import { BrazePlugin } from '@segment/analytics-react-native-plugin-braze';
.Expected Behavior
App should run correctly
Actual Incorrect Behavior
App freezes after loading bundle from Metro
Verbose Logs
Note: RNLocalization and RNEventEmitter are modules created for this project.
Additional Information
I originally raised this issue on the github for the segment Braze plugin, and you can find that thread here: segmentio/analytics-react-native#888
However, I've confirmed that it is a line from braze-react-native-sdk that is causing the problem: https://github.com/braze-inc/braze-react-native-sdk/blob/4ef01ede9c36a6f557d25cf7c704271c54d99a40/src/braze.js#L37C46-L37C46
It seems to be that I am not setting up the bridge correctly/something is incompatible between my app and the Braze iOS code. If I add a new bit of code to the constructor of my main App file to import
NativeModules.BrazeReactBridge
and create a NativeEventEmitter with it, it does not throw an error. Also, I can log out the BrazeReactBridge and see that it is NOT null, so it seems like some kind of race condition? The BrazeReactBridge is null when the Braze class from your sdk is instantiated.You can find my AppDelegate files here: https://drive.google.com/drive/folders/1hRVjZYsGNHjFJwZRbIOppcZQV-Htb-KZ?usp=sharing
Any support is greatly appreciated!
The text was updated successfully, but these errors were encountered: