Skip to content
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

Invariant Violation: new NativeEventEmitter() requires a non-null argument #2420

Open
remig17 opened this issue Aug 6, 2024 · 1 comment

Comments

@remig17
Copy link

remig17 commented Aug 6, 2024

I am encountering an issue with react-native-push-notification. Despite following the installation and configuration steps, I get the following error when running my React Native app:

ERROR Invariant Violation: new NativeEventEmitter() requires a non-null argument., js engine: hermes

  1. Steps to Reproduce:
    Install react-native-push-notification : npm install --save react-native-push-notification

  2. Configure react-native-push-notification in the project:

`import PushNotification from "react-native-push-notification";

PushNotification.configure({
  onRegister: function (token) {
    console.log("TOKEN:", token);
  },
  onNotification: function (notification) {
    console.log("NOTIFICATION:", notification);
    notification.finish(PushNotificationIOS.FetchResult.NoData);
  },
  permissions: {
    alert: true,
    badge: true,
    sound: true,
  },
  popInitialNotification: true,
  requestPermissions: true,
});`
  1. Run the app on iOS using Xcode.

Expected Behavior
The app should run without errors and handle push notifications as configured.

Actual Behavior
The app crashes with the error:

Invariant Violation: new NativeEventEmitter() requires a non-null argument.

Environment

React Native version: 0.73.6
react-native-push-notification version: 8.1.1
Platform: iOS
Hermes: true

@IsPriamo
Copy link

Usually this error is when you are using the new NativeEventEmitter() class to register an event, the instance of this class usually requires the event in question to be taken from react-native's NativeModule.

Try to remove the Pods and Podfile.lock and redo the installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants