react-native-background-task
react-native-background-task copied to clipboard
Stuck at BackgroundTask: Job is running
For me the adb logcat is stuck at this message 09-06 20:59:47.398 5218 5300 D BackgroundTask: Initializing 09-06 20:59:47.419 5218 5218 D BackgroundTask: Setting foreground true 09-06 21:00:02.645 5218 5300 D BackgroundTask: @ReactMethod BackgroundTask.schedule 09-06 21:05:12.487 5218 5218 D BackgroundTask: Setting foreground false 09-06 21:05:12.487 5218 5218 D BackgroundTask: Committing job schedule 09-06 21:15:01.462 5218 5385 D BackgroundTask: Job is running
my code for background task
class BackgroundTasks { constructor() { const pushNotifications = new PushNotifications();
BackgroundTask.define(() => {
console.log('Hello from a background task');
AsyncStorage.getItem('somekey').then((value) => {
// do some work
BackgroundTask.finish();
});
})
}
runBackgroundTask() {
BackgroundTask.schedule();
this.checkStatus();
}
async checkStatus() {
const status = await BackgroundTask.statusAsync()
console.log(status.available)
}
}
and in my app.js
constructor(){ this.backgroundTasks = new BackgroundTasks(); }
componentDidMount() {
console.log('starting background service');
this.backgroundTasks.runBackgroundTask();
}
@vinaygosain
try to put the BackgroundTask.define()
method out of the class and on the main index according to documentation.
check this out: https://github.com/jamesisaac/react-native-background-task#definetask
yeah, i have tried that also, but it didn't work, apparently, this lib doesn't work for android version>8.0.0
Any updates on this issue because I am running into a very similar issue.
Same problem here, any updates?
Same issue react native 0.61.5 Test on emulator Android 8.1.0