I have setup a job through firebase job dispatcher, which should execute after X-hours. It works fine when app is open or in background but not working when app is closed.
Too many people have faced this issue, even such issues are still open in Github, but I didn't find solution.
Here is my code:
public void setupJob(){
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
final int periodicity = (int) TimeUnit.HOURS.toSeconds(3);
final int toleranceInterval = 30;
Job myJob = dispatcher.newJobBuilder()
.setService(MyScheduler.class)
.setTag("MY_JOB_TAG")
.setRecurring(false)
.setLifetime(Lifetime.FOREVER)
.setTrigger(Trigger.executionWindow(periodicity, periodicity + toleranceInterval))
.setReplaceCurrent(false)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
.build();
dispatcher.mustSchedule(myJob);
}
Making .setRecurring(true) fires it but only once you open the app and then it repeats and works fine even if the app is closed.
Help please!