Open sandropoluan opened 6 years ago
My guess is this would be to do with navigator.geolocation.getCurrentPosition
being code which can't be run in the background. If you take out that line, and make the same fetch request with a dummy value for position, presumably it works?
I would recommend using a more specific library for this purpose, e.g.: https://github.com/transistorsoft/react-native-background-geolocation
I have this problem and I don't use navigator.geolocation at all. "react-native-background-task": "^0.2.1", "react-native": "^0.48.4",
@artemukolov What code are you trying to execute in your task?
So. Looks like I fix it by update RN to 49.5. But this requires React 16.beta.5 Be careful.
Has anyone found a different solution for this issue besides upgrading to RN 49.5 with React 16.beta.5? This is my background task:
BackgroundTask.define(() => { console.log('Hello from a background task') BackgroundTask.finish() })
.
It looks like it works when the app is in the background, but if I kill it then I get the 'Expected to run on UI thread' error. I tried commenting out the console log but the issue persists.
Expected to run on UI thread!
I got that error.My code