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

How to execute background task when Android app is closed?

Open diennguyentien opened this issue 7 years ago • 5 comments

Hi all, I already tried to set obj.allowExecutionInForeground to true in my options, but background jobs can not execute app when i closed or exists someone can help me?

diennguyentien avatar Nov 02 '17 05:11 diennguyentien

Have you tried the example project?

vikeri avatar Nov 02 '17 08:11 vikeri

@vikeri : Yes, i have tried in example this is my sourcode:

BackgroundJob.register({
  jobKey: workerNotify,
  job: () => {
   console.log(`Run with app closed`);
   // push notify used by firebase
 }
});
BackgroundJob.schedule({
      jobKey: workerNotify,
      period: 1000,
      exact: true,
      allowExecutionInForeground: true
    });

diennguyentien avatar Nov 02 '17 09:11 diennguyentien

And if you just put your app in the background you don't get any console logs?

vikeri avatar Nov 02 '17 09:11 vikeri

@vikeri : yes, I using firebase to push notify it's run normal with app state is active

diennguyentien avatar Nov 02 '17 10:11 diennguyentien

Same issue for my case. I can't print logs to the console, and can't run background notification when the app is closed. react-native: 0.61.5, react-native-background-job: 2.3.1

prettydev avatar Feb 14 '20 01:02 prettydev