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

Fix warning new NativeEventEmitter() called without... #520

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

elibroftw
Copy link

@elibroftw elibroftw commented Aug 5, 2023

Fix the warning new NativeEventEmitter() was called with a non-null argument without the required addListener and removeListener methods

Closes #359
Closes #366
Closes #367

Original patch source: https://stackoverflow.com/a/69650217/7732434

For those wanting this fix, instead of waiting for a merge, you can install the fork

yarn add react-native-background-timer@https://github.com/Spltthetnk/react-native-background-timer

Hopefully someone can fix the iOS warnings that probably exist (I'm on Windows, so I don't know).

Be sure to check out SplitTheTank (https://splitthetank.com) in the near future. 💙💜

…rgument without the required addListener and removeListener methods' on react-native 0.65 and android platform
@elibroftw elibroftw changed the title Fix warning 'new NativeEventEmitter() Fix warning new NativeEventEmitter() called without... Aug 5, 2023
@glenne
Copy link

glenne commented Sep 30, 2023

I agree with this fix. Please merge.

@HannahCarney
Copy link

Hey can someone merge this, kindly

@qnrjs42
Copy link

qnrjs42 commented Dec 12, 2023

I used patch-package.

// node_modules/react-native-background-timer/android/src/main/java/com/ocetnik/timer/BackgroundTimerModule.java

@ReactMethod
public void setTimeout(final int id, final double timeout) {
    Handler handler = new Handler();
    handler.postDelayed(new Runnable(){
        @Override
        public void run(){
            if (getReactApplicationContext().hasActiveCatalystInstance()) {
                getReactApplicationContext()
                    .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
                    .emit("backgroundTimer.timeout", id);
            }
       }
    }, (long) timeout);
}

// here
@ReactMethod
public void addListener(String eventName) {
  // Keep: Required for RN built in Event Emitter Calls.
}

// here
@ReactMethod
public void removeListeners(Integer count) {
  // Keep: Required for RN built in Event Emitter Calls.
}
npx patch-package react-native-background-timer

rm -rf node_modules

yarn install

yarn run start --reset-cache

yarn run android
yarn run ios

@phil-hudson
Copy link

hey can we merge this please?

@rimonhanna
Copy link

Agree with PR, please merge

@ArturV93
Copy link

ArturV93 commented Apr 5, 2024

please merge

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