react-native-background-timer icon indicating copy to clipboard operation
react-native-background-timer copied to clipboard

Fix warning new NativeEventEmitter() called without...

Open elibroftw opened this issue 1 year ago • 8 comments

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. 💙💜

elibroftw avatar Aug 05 '23 20:08 elibroftw

I agree with this fix. Please merge.

glenne avatar Sep 30 '23 21:09 glenne

Hey can someone merge this, kindly

HannahCarney avatar Nov 03 '23 21:11 HannahCarney

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

qnrjs42 avatar Dec 12 '23 17:12 qnrjs42

hey can we merge this please?

phil-hudson avatar Feb 03 '24 05:02 phil-hudson

Agree with PR, please merge

rimonhanna avatar Mar 26 '24 14:03 rimonhanna

please merge

ArturV93 avatar Apr 05 '24 10:04 ArturV93