jamesisaac / react-native-background-task

Periodic background tasks for React Native apps, cross-platform (iOS and Android), which run even when the app is closed.
MIT License
1.1k stars 111 forks source link

Not working on Android 8.0+ #63

Open adamivancza opened 5 years ago

adamivancza commented 5 years ago

I'm facing the same issue that's mentioned on this bug report: https://github.com/jamesisaac/react-native-background-task/issues/34

11-13 16:20:49.901 20728 20728 D BackgroundTask: Setting foreground false
11-13 16:20:49.901 20728 20728 D BackgroundTask: Committing job schedule
11-13 16:20:52.160 20728 20728 D ReactNative: ReactInstanceManager.detachViewFromInstance()
11-13 16:29:17.859 22953 22987 D BackgroundTask: Job is running

Then nothing happens - my actual task is never called after this point. Any idea how can I resolve this? Obviously setting targetSdk to 25 is not a valid solution anymore since Google requires us to use 26.

xuancong84 commented 5 years ago

Same to me. I have extensively tested. It does not work on Android 8.0+. No matter what I do, the defined task never gets running.

12-28 11:17:32.010  7497  7497 D ReactNative: ReactInstanceManager.ctor()
12-28 11:17:32.036  7497  7497 D ReactNative: ReactInstanceManager.createReactContextInBackground()
12-28 11:17:32.036  7497  7497 D ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
12-28 11:17:33.241  7497  7497 D ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()
12-28 11:17:33.242  7497  7497 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
12-28 11:17:33.243  7497  7497 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
12-28 11:17:33.254  7497  7530 D ReactNative: ReactInstanceManager.createReactContext()
12-28 11:17:33.557  7497  7530 D ReactNative: Initializing React Xplat Bridge.
12-28 11:17:33.560  7497  7530 D ReactNative: Initializing React Xplat Bridge before initializeBridge
12-28 11:17:33.565  7497  7530 D ReactNative: Initializing React Xplat Bridge after initializeBridge
12-28 11:17:33.566  7497  7530 D ReactNative: CatalystInstanceImpl.runJSBundle()
12-28 11:17:33.566  7497  7534 D ReactNative: ReactInstanceManager.setupReactContext()
12-28 11:17:33.567  7497  7534 D ReactNative: CatalystInstanceImpl.initialize()
12-28 11:17:33.625  7497  7534 D ReactNative: ReactInstanceManager.attachRootViewToInstance()
12-28 11:17:34.027  7497  7533 I ReactNativeJS: Running application "helloWord_native" with appParams: {"rootTag":1}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
12-28 11:17:57.743  7497  7497 D ReactNative: ReactInstanceManager.detachViewFromInstance()
anshumanburman commented 5 years ago

same error is occurring in my app. plz tell me any solution.

adamivancza commented 5 years ago

@anshumanburman eventually for android we've switched to https://github.com/vikeri/react-native-background-job

qlerebours commented 4 years ago

The library react-native-background-job works only on Android at the moment. To fix the bug on Android 8, a PR has been opened: https://github.com/jamesisaac/react-native-background-task/pull/64

danielfx90 commented 4 years ago

For those of you still looking for a solution, it seems (according to their README) that https://github.com/transistorsoft/react-native-background-fetch now supports both Android and iOS with a common API, i.e. exactly like this package does.