react-native-background-timer
react-native-background-timer copied to clipboard
null is not an object (evaluating 'RNBackgroundTimer.setTimeout') - RN version 0.60.4
I am continually getting this error thrown and it stops the background timer from working on Android. It works no issues on iOS however.
I am not using the setTimeout function at all, I am using BackgroundTimer.setInterval if the platform is Android and using BackgroundTimer.runBackgroundTimer for iOS as even though it says it is cross platform, it only seemed to work for iOS.
React Native version: 0.60.4 React: 16.9.0 react-native-background-timer: 2.1.1
I have tried manually linking as the readme suggests, but this did not resolve the issue. Any help would be much appreciated.
passiveMode = () => {
if (this.platform == 'ios') {
BackgroundTimer.runBackgroundTimer(() => {
this.main()
}, 6000);
} else {
this.bgIntFunc = BackgroundTimer.setInterval(() => {
this.main()
}, 6000);
}
this.active = false
}
As soon as the setInterval function gets called, the error is thrown and all the functionality stops for the background timer.
Try
rm package-lock.json || true && npm i && cd ios && rm -rf Pods || true && rm Podfile.lock || true && pod install && cd ../
Please run the below command:
rm -rf node_modules && yarn install && react-native link && cd android && ./gradlew clean
After running this command Open Android Studio and do these steps:
- delete .idea/caches(directory) .idea/modules.xml(file)
- delete app/build(directory)
- in file menu select 'Invalidate Caches / Restart'
after this let gradle sync finish and then start your server 'react-native start' and run the app. It will work.
Please run the below command:
rm -rf node_modules && yarn install && react-native link && cd android && ./gradlew clean
After running this command Open Android Studio and do these steps:
1. delete **.idea/caches**(directory) **.idea/modules.xml**(file) 2. delete **app/build**(directory) 3. in file menu select **'Invalidate Caches / Restart'**
after this let gradle sync finish and then start your server 'react-native start' and run the app. It will work.
Didn't solve the issue for me.
If you are using windows the correct command is (inside android folder) gradlew clean
not ./gradlew clean
also you need do "react-native run-android"(inside your main folder app)_ to reinstall the app with the correct dependencies
I'm also facing this problem although I already followed the README (manual linking included) :(