Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BackgroundFetch not running #3582

Open
leighquince opened this issue Feb 26, 2019 · 54 comments
Open

BackgroundFetch not running #3582

leighquince opened this issue Feb 26, 2019 · 54 comments
Assignees

Comments

@leighquince
Copy link

@leighquince leighquince commented Feb 26, 2019

Environment

Expo CLI 2.11.1 environment info:
    System:
      OS: macOS 10.14.3
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.6.0 - /usr/local/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.8.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmGlobalPackages:
      expo-cli: 2.11.1

app's target - iOS, Standalone

Steps to Reproduce

  1. Allow background fetch in app.json
"ios": {
    "infoPlist": {
        "UIBackgroundModes": [
		"location",
		"fetch"
	]
  1. define a task in App.js
defineHealthTask = () => {
   	TaskManager.defineTask(taskName, async () => {
   		try {
   			await UserRemoteLogService.logWithTaskType("STEPS_TASK_RUNNING");
   			return BackgroundFetch.Result.NewData;
   		} catch (error) {
   		        return BackgroundFetch.Result.Failed;
   		}
   	});
   };
  1. register task at some point of the apps running
await UserRemoteLogService.logWithTaskType("STEPS_TASK_REGISTRATION_REQUESTED");
	const pedometerAvailable = await Pedometer.isAvailableAsync();
	const backGroundFetchStatus = await BackgroundFetch.getStatusAsync();
	if (pedometerAvailable && BackgroundFetch.Status.Available === backGroundFetchStatus) {
		await BackgroundFetch.registerTaskAsync(taskName, {
			userBusinessId: user.businessId
		});
		UserRemoteLogService.logWithTaskType("STEPS_TASK_REGISTERED");
	}
  1. set minimum interval for task in seconds
    BackgroundFetch.setMinimumIntervalAsync(60);

Expected Behavior

App should periodically call my server to log that the background task is running

Actual Behavior

Never see the background task run, although i do see the logs that show the background task was registered. The logging service i use has been used to show when location background task has run so this logging service should log if the task runs

My main question is has anyone seen background fetch run? if so have i just configured it wrong?

@sjchmiela

This comment has been minimized.

Copy link
Contributor

@sjchmiela sjchmiela commented Feb 26, 2019

Hey, @leighquince! As noted in the documentation, TaskManager.defineTask has to be called in global scope of the app, not in a component's function (like defineHealthTask). Try moving call to defineTask to the global level of the app (like in the example in the documentation) and see if it helps.

@leighquince

This comment has been minimized.

Copy link
Author

@leighquince leighquince commented Feb 26, 2019

In my App.js I call defineHealthTask (it's not in a react component). Calling it directly in App.js or via a function that would be evaluated at the same time should have no difference? I'll give it a go though, thanks

@tcdavis

This comment has been minimized.

Copy link
Contributor

@tcdavis tcdavis commented Feb 26, 2019

Would help if you could give us a snack or toy repo demonstrating the issue if changing the call context doesn't resolve it

@leighquince

This comment has been minimized.

Copy link
Author

@leighquince leighquince commented Feb 27, 2019

A quick snack https://snack.expo.io/@domosafety/background-fetch.

Task is defined at top level, registered when App mounts, no logs are seen to show that the background task runs.

Also defining the task directly rather than through a call had no effect in my actual App.
Cheers

@Oakyden

This comment has been minimized.

Copy link

@Oakyden Oakyden commented Mar 4, 2019

Struggling with this too, i have defined a task in Global scope (GET_STEPS), but console logging the promise returns "undefined".

BackgroundFetch.registerTaskAsync(GET_STEPS) .then( (data) => {console.log("task data is ", data)} )

I put BackgroundFetch.registerTaskAsync in my app.js render method for now, but it appears to not work.

@superyarik

This comment has been minimized.

Copy link
Contributor

@superyarik superyarik commented Mar 5, 2019

@Oakyden there is no data income in BackgroundFetch. you can call fetch, process it and return BackgroundFetch.Result.### result.

@superyarik

This comment has been minimized.

Copy link
Contributor

@superyarik superyarik commented Mar 5, 2019

i can confirm that BackgroundFetch work for me, but very strange. looks like i can not call anything like in main app(asyncstorage, get coordinates or something like this) and frequency of calling very various, it's making debug hard. So i decide to wait android implementation.

@Oakyden

This comment has been minimized.

Copy link

@Oakyden Oakyden commented Mar 5, 2019

Can you share an example expo snack or similar @superyarik ? especially if you use a simple API example like https://jsonplaceholder.typicode.com/

@mskg

This comment has been minimized.

Copy link

@mskg mskg commented Mar 20, 2019

It took me a long while to understand what was my problem. The expo documentation is a bit misleading. According to Apple you MUST call BackgroundFetch.setMinimumIntervalAsync in order for the job to be scheduled.

So, you have to

  1. Always call TaskManager.defineTask.
  2. Check if task is registered with BackgroundFetch. If not, register.
  3. Always call BackgroundFetch.setMinimumIntervalAsync.

Be aware that an emulator does not run your task, that happens only on real devices.

The following worked for me:

export async function registerFetchTask() {
    TaskManager.defineTask(FETCH_TASKNAME, runBackgroundSaga);

    const status = await BackgroundFetch.getStatusAsync();
    switch (status) {
        case BackgroundFetch.Status.Restricted:
        case BackgroundFetch.Status.Denied:
            logger.log("Background execution is disabled");
            return;

        default: {
            logger.debug("Background execution allowed");

            let tasks = await TaskManager.getRegisteredTasksAsync();
            if (tasks.find(f => f.taskName === FETCH_TASKNAME) == null) {
                logger.log("Registering task");
                await BackgroundFetch.registerTaskAsync(FETCH_TASKNAME);

                tasks = await TaskManager.getRegisteredTasksAsync();
                logger.debug("Registered tasks", tasks);
            } else {
                logger.log(`Task ${FETCH_TASKNAME} already registered, skipping`);
            }

            logger.log("Setting interval to", INTERVAL);
            await BackgroundFetch.setMinimumIntervalAsync(INTERVAL);
        }
    }
}
@choco9620

This comment has been minimized.

Copy link

@choco9620 choco9620 commented Mar 20, 2019

Hello, I have the same problem, the global task was defined but it is not executed in the interval, is it possible that someone can share functional code ?, since the expo documentation does not define anything.

@tomas1000r

This comment has been minimized.

Copy link

@tomas1000r tomas1000r commented Mar 26, 2019

Hello, it looks like we need to use Location.startLocationUpdatesAsync('taskName') in order to get background tasks working. It also requires that we ask for the location permission and it should be set to "Allow always". It looks like that BackgroundFetch is tightly coupled with location. Don't know why.

@BrodaNoel

This comment has been minimized.

Copy link
Contributor

@BrodaNoel BrodaNoel commented Mar 28, 2019

@mskg you should call BackgroundFetch.setMinimumIntervalAsync(INTERVAL); only if you are registering the task, right? Check that in your code you are actually calling it always.

On other hand, remember that there is a function already created for doing that check: TaskManager.isTaskRegisteredAsync(TASK_NAME)

@mskg

This comment has been minimized.

Copy link

@mskg mskg commented Mar 28, 2019

@BrodaNoel no, you MUST call it every time when the App starts. See https://developer.apple.com/documentation/uikit/uiapplication/1623100-setminimumbackgroundfetchinterva

The isTaskRegisteredAsync would definitly be a shortcut for the code I posted. Still, it doesn't change the behavior.

@SowinskiMateusz

This comment has been minimized.

Copy link

@SowinskiMateusz SowinskiMateusz commented Mar 29, 2019

Hello, it looks like we need to use Location.startLocationUpdatesAsync('taskName') in order to get background tasks working. It also requires that we ask for the location permission and it should be set to "Allow always". It looks like that BackgroundFetch is tightly coupled with location. Don't know why.

Is it really true? This is the only command that fires the task? Does not it make sense? Is there any other command not related to Location?

@mskg

This comment has been minimized.

Copy link

@mskg mskg commented Apr 3, 2019

@SowinskiMateusz no, see my example above.

@Bug-Reaper

This comment has been minimized.

Copy link

@Bug-Reaper Bug-Reaper commented Apr 5, 2019

@mskg

Could you provide a more complete example, or possibly add comments to your original

@farzd

This comment has been minimized.

Copy link

@farzd farzd commented Apr 8, 2019

Doesnt appear to work for me either, my setup for geofencing works so following same convention, define task in global scope etc

  TaskManager.defineTask(client.tasks.background, () => {
    try {
      console.log('doesnt log')
      return BackgroundFetch.Result.NewData
    } catch (error) {
      return BackgroundFetch.Result.Failed
    }
  })

Manual trigger inside a component

    let isRegistered = await TaskManager.isTaskRegisteredAsync(
      client.tasks.background
    )
    if (isRegistered) {
      console.log('unregister task ...')
      await BackgroundFetch.unregisterTaskAsync(client.tasks.background)
    }

    const status = await BackgroundFetch.getStatusAsync()
    console.log(BackgroundFetch.Status[status]) //Available 
    await BackgroundFetch.setMinimumIntervalAsync(100)
    await BackgroundFetch.registerTaskAsync(client.tasks.background)

adding this at the end appears to make it work, as suggested by @tomas1000r why? @tsapeta

    Location.startLocationUpdatesAsync(client.tasks.background)
@farzd

This comment has been minimized.

Copy link

@farzd farzd commented Apr 8, 2019

The example provided here: https://github.com/expo/expo/blob/master/apps/native-component-list/screens/BackgroundFetchScreen.js

I've tailored it to work without the alpha release and without react navigation,
it registers the task and task status is available but no logs for fetch [tested on iPhone7, ios12, via expo client]

code: https://pastebin.com/gNU5QnJv

@tsapeta

This comment has been minimized.

Copy link
Member

@tsapeta tsapeta commented Apr 8, 2019

So, you have to

  1. Always call TaskManager.defineTask.
  2. Check if task is registered with BackgroundFetch. If not, register.
  3. Always call BackgroundFetch.setMinimumIntervalAsync.

re: 2. - there is no need to check if background fetch task is already registered - if you try to register it again, then it just overwrites the previously registered task, which is fine 👌 Except that, these steps look good.

adding this at the end appears to make it work, as suggested by @tomas1000r why? @tsapeta

    Location.startLocationUpdatesAsync(client.tasks.background)

I'll try to check it out soon, but it seems weird to me as there is no connection between location and background fetch. They are completely independent features. My assumption is that, if you turn on background location then your app is actually always active, so the background fetch can occur in the time you set by setMinimumIntervalAsync. However, if the app is not active, then it strongly depends on the operating system and how you use the application. Apple has its own algorithm which defines how often the background fetch should trigger, based on your own usage of the app. If you use it a lot, then it will fetch as often as possible, but if you use it like at 4pm every day, the background fetch should trigger just before, so your data is updated when you launch it. So imho you shouldn't worry about the task not being done on time - Apple knows better when to call it 😅

@farzd

This comment has been minimized.

Copy link

@farzd farzd commented Apr 8, 2019

@tsapeta can you please explain why this doesnt work: https://pastebin.com/gNU5QnJv
its taken from your master branch and altered slightly so updates are shown when app is brought to foreground, the fetch call is never made.

@tsapeta

This comment has been minimized.

Copy link
Member

@tsapeta tsapeta commented Apr 8, 2019

@farzd
In this pastebin, you're passing a second argument with task options to BackgroundFetch.registerTaskAsync that is not yet available in Expo Client. It will be once we release SDK33. In SDK32 the minimum interval must be set by BackgroundFetch.setMinimumIntervalAsync - and it must be called because iOS defaults to a really big number.
Also, keep in mind that BackgroundFetch is not supported on Android in SDK32.

@farzd

This comment has been minimized.

Copy link

@farzd farzd commented Apr 8, 2019

thanks for your time @tsapeta, i realised the arguments were for SDK33 but assumed it would no op anyway.
I've tried the code with explicitly setting BackgroundFetch.setMinimumIntervalAsync however it has made no difference, this is the issue a lot of people on this thread are facing.

Background app refresh is on in settings etc, not sure what else to check

@mskg

This comment has been minimized.

Copy link

@mskg mskg commented Apr 10, 2019

At least according to my experience here: On iOS it is actually really like @tsapeta described. The time you set is just an indication on how often data might change. If it doesn’t (depending on the result), you‘re scheduled less frequent. Also, if you don’t use the App, the fetch will most likely not run.

In my case, the fetch currently runs directly after/when I open the App in the morning. I seem to do that regularly :)

@baptistemanson

This comment has been minimized.

Copy link

@baptistemanson baptistemanson commented May 3, 2019

I directly tested the snack on a ios device and on a simulator using the expo app, and I cannot get

console.log('background fetch running') ;

to display, with or without remote debugging on, even after waiting 10min for it to occur. How can I debug further?

@g-bastianelli

This comment has been minimized.

Copy link

@g-bastianelli g-bastianelli commented Jun 19, 2019

I m unable to make it works on ios with SDK33. Can have a working snack or example?

@mslavik2

This comment has been minimized.

Copy link

@mslavik2 mslavik2 commented Jun 20, 2019

I am having trouble with SDK33 on ios as well. A working snack would be very helpful in debugging the issue and solidify the steps required to make the background fetch work.

@Kency1013

This comment has been minimized.

Copy link

@Kency1013 Kency1013 commented Jul 19, 2019

BackgroundFetch not working with me. I use expo client test it. Is it only working in standalone app?

@amaurymartiny

This comment has been minimized.

Copy link
Contributor

@amaurymartiny amaurymartiny commented Jul 19, 2019

I'm using it as a standalone app on Android.

What I noticed is that when the app is not in the foreground but not terminated, i.e. in the Recents Screen, the BackgroundFetch works well.

When the app is terminated (not in the Recents Screen), then BackgroundFetch never happens.

Is this an expected behavior?

Note : I manually set stopOnTerminate to false in the options.

Edit: in adb logcat, every time I close the app, I get the line

07-23 13:31:00.926   783   797 I ActivityManager: Killing 13019:com.shitismoke.app/u0a146 (adj 900): remove task
@Hawods

This comment has been minimized.

Copy link

@Hawods Hawods commented Jul 19, 2019

Mark. Waiting for the next version to close this issue.

@fhelwanger

This comment has been minimized.

Copy link

@fhelwanger fhelwanger commented Aug 6, 2019

I'm also having the same problem as @amaurymartiny, where the background task is only executed when the app is in the Recents Screen. When the app is terminated the background task doesn't execute.

If it's not expected behavior I'd be happy to provide a simple snack to test.

@oguzhankarabulut

This comment has been minimized.

Copy link

@oguzhankarabulut oguzhankarabulut commented Aug 6, 2019

@fhelwanger me too :(

@kpheasey

This comment has been minimized.

Copy link

@kpheasey kpheasey commented Aug 9, 2019

Using Expo SDK 34 with a modified solution from @mskg, I was able to get my tasks running in a stand alone app. The basic idea is to call BackgroundFetch.setMinimumIntervalAsync AFTER the task has been registered. While the original solution does have await, it was not clear to me that it was an essential part.

TaskManager.defineTask should still be called in the global scope.

BackgroundFetch.registerTaskAsync(
    TASK_NAME,
    {
      minimumInterval: 60,
      stopOnTerminate: false,
      startOnBoot: true,
    },
).then(() => BackgroundFetch.setMinimumIntervalAsync(60));

I saw mention of the minimumInterval option on BackgroundFetch.registerTaskAsync(), that's why it's included. I have not tested it without it, because it requires a new TestFlight build.

BackgroundFetch does not work on iOS Simulator, you can only trigger a BackgroundFetch using Xcode. So, unless you use ExpoKit, the only way to test iOS BackgroundFetch is to push a build to TestFlight!

EDIT: BackgroundFetch is not running on all devices. the issue appears to be device specific, there are conflicting results across the same os version for both android and ios.

@erin-truong

This comment has been minimized.

Copy link

@erin-truong erin-truong commented Aug 29, 2019

I use Expo SDK 34. I use expo client test BackgroundFetch. The TaskManager is registered but never run. Can have a working snack or example?

@niv-breez

This comment has been minimized.

Copy link

@niv-breez niv-breez commented Sep 3, 2019

@superyarik did AsyncStorage work for you? what did you do in order to make it work?
Thanks

@NickR49

This comment has been minimized.

Copy link

@NickR49 NickR49 commented Sep 15, 2019

@erin-truong Here's a working example for both iOS and Android (though Android is only running background fetch once a minute) - https://github.com/NickR49/background-fetch

@niv-breez

This comment has been minimized.

Copy link

@niv-breez niv-breez commented Sep 15, 2019

@NickR49

This comment has been minimized.

Copy link

@NickR49 NickR49 commented Sep 18, 2019

Hi @niv-breez , no I haven't tested those two things. However you could take that code and add those things to test it out.

@NickR49

This comment has been minimized.

Copy link

@NickR49 NickR49 commented Sep 18, 2019

Hi all,

What I'm finding is that I must have the await Location.startLocationUpdatesAsync(BACKGROUND_FETCH_TASK); code to make background fetch work for iOS. However when I use that then unregistering the task fails with Invalid task consumer. Cannot unregister task with name 'background-fetch' because it is associated with different consumer class.. I'm guessing this is because the task started as a backgroundFetch task type and got changed to a location task type.

Any idea why calling Location.startLocationUpdatesAsync(taskName) is necessary to get background fetch working for iOS @tsapeta ?

cheers
Nick

@holgersindbaek

This comment has been minimized.

Copy link

@holgersindbaek holgersindbaek commented Oct 23, 2019

Is there any update on this?

I seem to have gotten it to work now, but the backgroundfetch only runs once or day (if at all) even though it's set to run every half an hour.

Asking people to always allow location tracking doesn't seem to be a viable option to me, since my app has nothing to do with a users location at all.

Is this really how it's supposed to work? If that's really the case, it's seems to me to be a pretty useless API?!

@jeromecornet

This comment has been minimized.

Copy link
Contributor

@jeromecornet jeromecornet commented Dec 4, 2019

This is likely due to the loader error I raised in #6290 and that I think ends up being the problem in #6017 as well.

But yes, as it stands I think the BackgroundFetch API is just broken

@rosnaib11

This comment has been minimized.

Copy link

@rosnaib11 rosnaib11 commented Dec 23, 2019

Same problem, not working. I already test on standalone, it trigger only once. I'm using android. I don't know how this supposed to work because on android it requires foreground service to preserve and don't kill the process running on the background. Instead, I just use the Location.startLocationUpdatesAsync for alternative but not that efficient. I need to run my task exactly every 1 minute and Location.startLocationUpdatesAsync triggers still depends on gps accuracy.

@kpheasey

This comment has been minimized.

Copy link

@kpheasey kpheasey commented Dec 23, 2019

@rosnaib11

I need to run my task exactly every 1 minute

As I understand it, it's not possible to run it every 1 minute. The OS batches background jobs from multiple applications and runs them based on some internal scheduling. The requested run time is simply a suggestion to the OS.

The BackgroundFetch documentation touches on this briefly.

Sets the minimum number of seconds that must elapse before another background fetch can be initiated. This value is advisory only and does not indicate the exact amount of time expected between fetch operations.
This method doesn't take any effect on Android.

@TheHunterDog

This comment has been minimized.

Copy link

@TheHunterDog TheHunterDog commented Dec 26, 2019

any fix up yet ?
or some example code I can't really figure this out if its fixed

@jeromecornet

This comment has been minimized.

Copy link
Contributor

@jeromecornet jeromecornet commented Dec 27, 2019

No, I tested it on SDK36 and it's still broken

@tuzz

This comment has been minimized.

Copy link

@tuzz tuzz commented Jan 7, 2020

This seems to work for me on Android in the simulator. I haven't tested on iOS.

Update: This only works when the app is suspended, there's still a bug that means this won't work when the app is terminated or after the phone reboots and the app hasn't opened yet.

I wrote a base class to handle defining and registering tasks, then extended it.

background_task.js (base class)

import * as TaskManager from "expo-task-manager";
import * as BackgroundFetch from "expo-background-fetch";

const Result = BackgroundFetch.Result;

class BackgroundTask {
  static name() {
    throw new Error("Implement me");
  }

  // Make this method return true if new data was fetched.
  static async run() {
    throw new Error("Implement me");
  }

  static enable({ log=false } = {}) {
    const name = this.name();
    const options = { stopOnTerminate: false, startOnBoot: true };
    const interval = 15; // minutes;

    log && console.log(`Defining ${name} background task...`);
    TaskManager.defineTask(name, () => this.runSafely(name, log));

    return BackgroundFetch.registerTaskAsync(name, options).then(() => {
      BackgroundFetch.setMinimumIntervalAsync(interval);
      log && console.log(`Successfully registered ${name} background task`);
    });
  }

  static async runSafely (name, log) {
    log && console.log(`Running ${name} background task...`);

    try {
      const bool = await this.run();
      return bool ? Result.NewData : Result.NoData;

    } catch (error) {
      log && console.error(`Error running ${name} background task:`, error);
      return Result.Failed;
    }
  }
}

export default BackgroundTask;

my_task.js (sub class)

import BackgroundTask from "./background_task";

class MyTask extends BackgroundTask {
  static name() {
    return "MyTask";
  }

  static async run() {
    // await fetch(...);
    return true;
  }
};

export default MyTask;

App.js

import MyTask from "./my_task";

MyTask.enable({ log: true });

// ...

I also wrote some Jest tests for the BackgroundTask base class.

background_task_spec.js

import BackgroundTask from "../../app/tasks/background_task";

import * as TaskManager from "expo-task-manager";
import * as BackgroundFetch from "expo-background-fetch";

jest.mock("expo-task-manager");
jest.mock("expo-background-fetch");

class TestBackgroundTask extends BackgroundTask {
  static name() {
    return "task name";
  }

  static async run() {
    this.taskHasRun = true;
  }
}

describe("BackgroundTask", () => {
  beforeEach(() => {
    BackgroundFetch.registerTaskAsync.mockResolvedValue();
    TestBackgroundTask.taskHasRun = false;
  });

  it("defines a TaskManager task", () => {
    TestBackgroundTask.enable();

    expect(TaskManager.defineTask)
      .lastCalledWith("task name", expect.anything());
  });

  it("sets the TaskManager task to the run function of the class", () => {
    TestBackgroundTask.enable();

    const lastCall = TaskManager.defineTask.mock.calls[0];
    const definedTask = lastCall[1];

    expect(TestBackgroundTask.taskHasRun).toBe(false);

    definedTask();
    expect(TestBackgroundTask.taskHasRun).toBe(true);
  });

  it("registers the task with BackgroundFetch", () => {
    TestBackgroundTask.enable();

    expect(BackgroundFetch.registerTaskAsync)
      .lastCalledWith("task name", expect.anything());
  });

  it("runs the task even if the phone reboots or the app terminates", () => {
    TestBackgroundTask.enable();

    const expectedOptions = { startOnBoot: true, stopOnTerminate: false };

    expect(BackgroundFetch.registerTaskAsync)
      .lastCalledWith(expect.anything(), expectedOptions);
  });

  it("runs the task every 15 minutes", async () => {
    await TestBackgroundTask.enable();

    expect(BackgroundFetch.setMinimumIntervalAsync).lastCalledWith(15);
  });

  it("can optionally log to the console", () => {
    jest.spyOn(global.console, "log").mockImplementation();

    TestBackgroundTask.enable({ log: false });
    expect(console.log).not.toHaveBeenCalled();

    TestBackgroundTask.enable({ log: true });
    expect(console.log).toHaveBeenCalled();
  });
});

Hopefully this helps someone.

@jeromecornet

This comment has been minimized.

Copy link
Contributor

@jeromecornet jeromecornet commented Jan 7, 2020

@tuzz thanks for the code... it's not substantially different from the example I posted, so I'm a bit confused as to why it would behave differently.
When you say 'it works' can you share whether you mean that:

  • the tests pass
  • the task gets executed while the app is still in the recently used apps (i.e. backgrounded)
  • the task gets executed after the app was killed (removed from the recently used apps)
  • the task gets executed after the phone was rebooted but before the app was restarted

Please let us know (as well as expo SDK version android simulator version, etc...) to narrow down the difference.

@tuzz

This comment has been minimized.

Copy link

@tuzz tuzz commented Jan 7, 2020

The tests pass and the task gets executed while the app is in the recently used apps.

I'm not sure about the other two cases, I'll check them tomorrow and do some testing on a real device.

$ expo --version
3.11.1

$ cat yarn.lock | grep ^expo@ -A 1
expo@^35.0.0:
  version "35.0.1"

Android simulator:

Screenshot 2020-01-07 at 17 55 50

@jeromecornet

This comment has been minimized.

Copy link
Contributor

@jeromecornet jeromecornet commented Jan 7, 2020

Ah ok that makes sense... the problem is with the last 2 cases, i.e. background fetch while the app is not running. (it works when the app is backgrounded)
The bug seems to be related to the way the app gets loaded when it's triggered by the task service which causes the app to crash and the task to get removed (see #6290 for more details)

@tuzz

This comment has been minimized.

Copy link

@tuzz tuzz commented Jan 8, 2020

You're right, it doesn't work for the last two cases - only when the app is suspended.

Thanks for clearing that up.

@jeromecornet

This comment has been minimized.

Copy link
Contributor

@jeromecornet jeromecornet commented Jan 8, 2020

@tsapeta any movement on this issue ? Let us know what we can do to help troubleshoot this issue.

@jeromecornet

This comment has been minimized.

Copy link
Contributor

@jeromecornet jeromecornet commented Jan 14, 2020

I've submitted a PR to the doc stating that the feature does not work on devices/simulators in #6767 , we can always switch it back if the issue is fixed

@brentvatne

This comment has been minimized.

Copy link
Member

@brentvatne brentvatne commented Jan 14, 2020

@tsapeta will investigate this after he wraps up his current project

@jeromecornet

This comment has been minimized.

Copy link
Contributor

@jeromecornet jeromecornet commented Jan 14, 2020

ok, thanks for the heads up @brentvatne

@BrodaNoel

This comment has been minimized.

Copy link
Contributor

@BrodaNoel BrodaNoel commented Jan 18, 2020

There is something that I still can't get:
Is it supposed to work well in the Expo App (iOS), when the app is backgrounded?
I have the app (in Expo App) opened in background, and it doesn't work.

Does it only work after creating & publishing a build?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.