Skip to content

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

Open
elibroftw wants to merge 1 commit intoocetnik:masterfrom
Spltthetnk:master
Open

Fix warning new NativeEventEmitter() called without...#520
elibroftw wants to merge 1 commit intoocetnik:masterfrom
Spltthetnk:master

Conversation

@elibroftw
Copy link
Copy Markdown

@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
Copy Markdown

glenne commented Sep 30, 2023

I agree with this fix. Please merge.

@HannahCarney
Copy link
Copy Markdown

Hey can someone merge this, kindly

@qnrjs42
Copy link
Copy Markdown

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
Copy Markdown

hey can we merge this please?

@rimonhanna
Copy link
Copy Markdown

Agree with PR, please merge

@ArturV93
Copy link
Copy Markdown

ArturV93 commented Apr 5, 2024

please merge

@SuPeRZ66
Copy link
Copy Markdown

SuPeRZ66 commented Nov 8, 2024

Please merge

@nidhal-cherni
Copy link
Copy Markdown

Merge this please

@HadrienGrenacs
Copy link
Copy Markdown

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